code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def add_device(dev): global DEV_IDX, DEFAULT_DEV with DEV_LOCK: for idx in range(len(DEVS)): test_dev = DEVS[idx] if test_dev.dev_name_short == dev.dev_name_short: if test_dev is DEFAULT_DEV: DEFAULT_DEV = None del DEVS[idx] break if find_device_by_name(dev.name): dev.name += '-%d' % DEV_IDX dev.name_path = '/' + dev.name + '/' DEVS.append(dev) DEV_IDX += 1 if DEFAULT_DEV is None: DEFAULT_DEV = dev
module function_definition identifier parameters identifier block global_statement identifier identifier with_statement with_clause with_item identifier block for_statement identifier call identifier argument_list call identifier argument_list identifier block expression_statement assignment identifier subscript identifier identifier if_statement comparison_operator attribute identifier identifier attribute identifier identifier block if_statement comparison_operator identifier identifier block expression_statement assignment identifier none delete_statement subscript identifier identifier break_statement if_statement call identifier argument_list attribute identifier identifier block expression_statement augmented_assignment attribute identifier identifier binary_operator string string_start string_content string_end identifier expression_statement assignment attribute identifier identifier binary_operator binary_operator string string_start string_content string_end attribute identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier expression_statement augmented_assignment identifier integer if_statement comparison_operator identifier none block expression_statement assignment identifier identifier
Adds a device to the list of devices we know about.
def read_examples(input_file): examples = [] unique_id = 0 with open(input_file, "r", encoding='utf-8') as reader: while True: line = reader.readline() if not line: break line = line.strip() text_a = None text_b = None m = re.match(r"^(.*) \|\|\| (.*)$", line) if m is None: text_a = line else: text_a = m.group(1) text_b = m.group(2) examples.append( InputExample(unique_id=unique_id, text_a=text_a, text_b=text_b)) unique_id += 1 return examples
module function_definition identifier parameters identifier block expression_statement assignment identifier list expression_statement assignment identifier integer with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end as_pattern_target identifier block while_statement true block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement not_operator identifier block break_statement expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier none expression_statement assignment identifier none expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement comparison_operator identifier none block expression_statement assignment identifier identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list integer expression_statement assignment identifier call attribute identifier identifier argument_list integer expression_statement call attribute identifier identifier argument_list call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier expression_statement augmented_assignment identifier integer return_statement identifier
Read a list of `InputExample`s from an input file.
def cleanup_key(name): name = name.lstrip('+') is_keypad = name.startswith('KP_') for mod in ('Meta_', 'Control_', 'dead_', 'KP_'): if name.startswith(mod): name = name[len(mod):] if name == 'Remove': name = 'Delete' elif name == 'Delete': name = 'Backspace' if name.endswith('_r'): name = 'right ' + name[:-2] if name.endswith('_l'): name = 'left ' + name[:-2] return normalize_name(name), is_keypad
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end for_statement identifier tuple string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block if_statement call attribute identifier identifier argument_list identifier block expression_statement assignment identifier subscript identifier slice call identifier argument_list identifier if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier string string_start string_content string_end elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier string string_start string_content string_end if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier binary_operator string string_start string_content string_end subscript identifier slice unary_operator integer if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier binary_operator string string_start string_content string_end subscript identifier slice unary_operator integer return_statement expression_list call identifier argument_list identifier identifier
Formats a dumpkeys format to our standard.
def export_modified_data(self): result = {key: None for key in self.__deleted_fields__} for key, value in self.__modified_data__.items(): if key in result.keys(): continue try: result[key] = value.export_modified_data() except AttributeError: result[key] = value for key, value in self.__original_data__.items(): if key in result.keys(): continue try: if value.is_modified(): result[key] = value.export_modified_data() except AttributeError: pass return result
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary_comprehension pair identifier none for_in_clause identifier attribute identifier identifier for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block if_statement comparison_operator identifier call attribute identifier identifier argument_list block continue_statement try_statement block expression_statement assignment subscript identifier identifier call attribute identifier identifier argument_list except_clause identifier block expression_statement assignment subscript identifier identifier identifier for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block if_statement comparison_operator identifier call attribute identifier identifier argument_list block continue_statement try_statement block if_statement call attribute identifier identifier argument_list block expression_statement assignment subscript identifier identifier call attribute identifier identifier argument_list except_clause identifier block pass_statement return_statement identifier
Get the modified data
def headers(self): d = {} for k, v in self.message.items(): d[k] = decode_header_part(v) return d
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block expression_statement assignment subscript identifier identifier call identifier argument_list identifier return_statement identifier
Return only the headers as Python object
def initLogger(): global logger logger = logging.getLogger('root') logger.setLevel(logging.DEBUG) ch = logging.StreamHandler(sys.stdout) ch.setLevel(logging.INFO) formatter = logging.Formatter("[%(asctime)s] %(levelname)s: %(message)s", "%Y-%m-%d %H:%M:%S") ch.setFormatter(formatter) logger.addHandler(ch)
module function_definition identifier parameters block global_statement identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier
This code taken from Matt's Suspenders for initializing a logger
def post(self): self._construct_post_data() post_args = {"json": self.post_data} self.http_method_args.update(post_args) return self.http_method("POST")
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier dictionary pair string string_start string_content string_end attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list string string_start string_content string_end
Makes the HTTP POST to the url sending post_data.
def getPyClass(self): if self.hasExtPyClass(): classInfo = self.extPyClasses[self.name] return ".".join(classInfo) return 'Holder'
module function_definition identifier parameters identifier block if_statement call attribute identifier identifier argument_list block expression_statement assignment identifier subscript attribute identifier identifier attribute identifier identifier return_statement call attribute string string_start string_content string_end identifier argument_list identifier return_statement string string_start string_content string_end
Name of generated inner class that will be specified as pyclass.
def dump_edn_val(v): " edn simple value dump" if isinstance(v, (str, unicode)): return json.dumps(v) elif isinstance(v, E): return unicode(v) else: return dumps(v)
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end if_statement call identifier argument_list identifier tuple identifier identifier block return_statement call attribute identifier identifier argument_list identifier elif_clause call identifier argument_list identifier identifier block return_statement call identifier argument_list identifier else_clause block return_statement call identifier argument_list identifier
edn simple value dump
def _get_prog_memory(resources, cores_per_job): out = None for jvm_opt in resources.get("jvm_opts", []): if jvm_opt.startswith("-Xmx"): out = _str_memory_to_gb(jvm_opt[4:]) memory = resources.get("memory") if memory: out = _str_memory_to_gb(memory) prog_cores = resources.get("cores") if out and prog_cores and int(prog_cores) == 1 and cores_per_job > int(prog_cores): out = out / float(cores_per_job) return out
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier none for_statement identifier call attribute identifier identifier argument_list string string_start string_content string_end list block if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list subscript identifier slice integer expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement boolean_operator boolean_operator boolean_operator identifier identifier comparison_operator call identifier argument_list identifier integer comparison_operator identifier call identifier argument_list identifier block expression_statement assignment identifier binary_operator identifier call identifier argument_list identifier return_statement identifier
Get expected memory usage, in Gb per core, for a program from resource specification.
def namedb_get_num_historic_names_by_address( cur, address ): select_query = "SELECT COUNT(*) FROM name_records JOIN history ON name_records.name = history.history_id " + \ "WHERE history.creator_address = ?;" args = (address,) count = namedb_select_count_rows( cur, select_query, args ) return count
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier tuple identifier expression_statement assignment identifier call identifier argument_list identifier identifier identifier return_statement identifier
Get the number of names owned by an address throughout history
def send_router_port_msg(self, tenant_id, tenant_name, router_id, net_id, subnet_id, seg, status): data = self.prepare_router_vm_msg(tenant_id, tenant_name, router_id, net_id, subnet_id, seg, status) if data is None: return False timestamp = time.ctime() pri = Q_PRIORITY LOG.info("Sending native FW data into queue %(data)s", {'data': data}) self.que_obj.put((pri, timestamp, data)) return True
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier identifier identifier identifier identifier if_statement comparison_operator identifier none block return_statement false expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end dictionary pair string string_start string_content string_end identifier expression_statement call attribute attribute identifier identifier identifier argument_list tuple identifier identifier identifier return_statement true
Sends the router port message to the queue.
def choice_explanation(value: str, choices: Iterable[Tuple[str, str]]) -> str: for k, v in choices: if k == value: return v return ''
module function_definition identifier parameters typed_parameter identifier type identifier typed_parameter identifier type generic_type identifier type_parameter type generic_type identifier type_parameter type identifier type identifier type identifier block for_statement pattern_list identifier identifier identifier block if_statement comparison_operator identifier identifier block return_statement identifier return_statement string string_start string_end
Returns the explanation associated with a Django choice tuple-list.
def tospark(self, engine=None): from thunder.images.readers import fromarray if self.mode == 'spark': logging.getLogger('thunder').warn('images already in spark mode') pass if engine is None: raise ValueError('Must provide a SparkContext') return fromarray(self.toarray(), engine=engine)
module function_definition identifier parameters identifier default_parameter identifier none block import_from_statement dotted_name identifier identifier identifier dotted_name identifier if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement call attribute call attribute identifier identifier argument_list string string_start string_content string_end identifier argument_list string string_start string_content string_end pass_statement if_statement comparison_operator identifier none block raise_statement call identifier argument_list string string_start string_content string_end return_statement call identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier identifier
Convert to distributed spark mode.
def c_member_funcs(self, for_struct=False): decls = [ '{} *{};'.format(self._c_type_name(name), name) for name, dummy_args in self.funcs ] if for_struct: return decls return [self._c_mod_decl()] + decls
module function_definition identifier parameters identifier default_parameter identifier false block expression_statement assignment identifier list_comprehension call attribute string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list identifier identifier for_in_clause pattern_list identifier identifier attribute identifier identifier if_statement identifier block return_statement identifier return_statement binary_operator list call attribute identifier identifier argument_list identifier
Get the decls of the module.
def save(self, filename): import dill tmpmodelparams = self.modelparams.copy() fv_extern_name = None if "fv_extern" in tmpmodelparams: tmpmodelparams.pop("fv_extern") sv = { "modelparams": tmpmodelparams, "mdl": self.mdl, } sss = dill.dumps(self.modelparams) logger.debug("pickled " + str(sss)) dill.dump(sv, open(filename, "wb"))
module function_definition identifier parameters identifier identifier block import_statement dotted_name identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier none if_statement comparison_operator string string_start string_content string_end identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier call identifier argument_list identifier string string_start string_content string_end
Save model to pickle file. External feature function is not stored
def format_idp_cert_multi(self): if 'x509certMulti' in self.__idp: if 'signing' in self.__idp['x509certMulti']: for idx in range(len(self.__idp['x509certMulti']['signing'])): self.__idp['x509certMulti']['signing'][idx] = OneLogin_Saml2_Utils.format_cert(self.__idp['x509certMulti']['signing'][idx]) if 'encryption' in self.__idp['x509certMulti']: for idx in range(len(self.__idp['x509certMulti']['encryption'])): self.__idp['x509certMulti']['encryption'][idx] = OneLogin_Saml2_Utils.format_cert(self.__idp['x509certMulti']['encryption'][idx])
module function_definition identifier parameters identifier block if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block if_statement comparison_operator string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end block for_statement identifier call identifier argument_list call identifier argument_list subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end block expression_statement assignment subscript subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end identifier call attribute identifier identifier argument_list subscript subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end identifier if_statement comparison_operator string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end block for_statement identifier call identifier argument_list call identifier argument_list subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end block expression_statement assignment subscript subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end identifier call attribute identifier identifier argument_list subscript subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end identifier
Formats the Multple IdP certs.
def makeHTML(self,mustachepath,htmlpath): subs = dict() if self.title: subs["title"]=self.title subs["has_title"]=True else: subs["has_title"]=False subs["font_size"] = self.font_size subs["font_family"] = self.font_family subs["colorscheme"] = self.colorscheme subs["title_color"] = self.title_color subs["bgcolor"] = self.bgcolor with open(mustachepath,'r') as infile: mustache_text = pystache.render(infile.read(), subs) with open(htmlpath,'w+') as outfile: outfile.write(mustache_text)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call identifier argument_list if_statement attribute identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end true else_clause block expression_statement assignment subscript identifier string string_start string_content string_end false expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier
Write an html file by applying this ideogram's attributes to a mustache template.
def _compute_fixed(self): try: lon, lat = np.meshgrid(self.lon, self.lat) except: lat = self.lat phi = np.deg2rad(lat) try: albedo = self.a0 + self.a2 * P2(np.sin(phi)) except: albedo = np.zeros_like(phi) dom = next(iter(self.domains.values())) self.albedo = Field(albedo, domain=dom)
module function_definition identifier parameters identifier block try_statement block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier except_clause block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier try_statement block expression_statement assignment identifier binary_operator attribute identifier identifier binary_operator attribute identifier identifier call identifier argument_list call attribute identifier identifier argument_list identifier except_clause block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list call identifier argument_list call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier call identifier argument_list identifier keyword_argument identifier identifier
Recompute any fixed quantities after a change in parameters
def _wrap_measure(individual_group_measure_process, group_measure, loaded_processes): def wrapped_measure(state_collection,overriding_parameters=None,loggers=None): if loggers == None: loggers = funtool.logger.set_default_loggers() if loaded_processes != None : if group_measure.grouping_selectors != None: for grouping_selector_name in group_measure.grouping_selectors: state_collection= funtool.state_collection.add_grouping(state_collection, grouping_selector_name, loaded_processes) for group in funtool.state_collection.groups_in_grouping(state_collection, grouping_selector_name): analysis_collection = funtool.analysis.AnalysisCollection(None,group,{},{}) if group_measure.analysis_selectors != None: for analysis_selector in group_measure.analysis_selectors: analysis_collection = loaded_processes["analysis_selector"][analysis_selector].process_function(analysis_collection,state_collection) if analysis_collection != None: individual_group_measure_process(analysis_collection,state_collection) return state_collection return wrapped_measure
module function_definition identifier parameters identifier identifier identifier block function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list if_statement comparison_operator identifier none block if_statement comparison_operator attribute identifier identifier none block for_statement identifier attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier identifier for_statement identifier call attribute attribute identifier identifier identifier argument_list identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list none identifier dictionary dictionary if_statement comparison_operator attribute identifier identifier none block for_statement identifier attribute identifier identifier block expression_statement assignment identifier call attribute subscript subscript identifier string string_start string_content string_end identifier identifier argument_list identifier identifier if_statement comparison_operator identifier none block expression_statement call identifier argument_list identifier identifier return_statement identifier return_statement identifier
Creates a function on a state_collection, which creates analysis_collections for each group in the collection.
def skip_coords(c): if c == "{{coord|LAT|LONG|display=inline,title}}": return True if c.find("globe:") >= 0 and c.find("globe:earth") == -1: return True return False
module function_definition identifier parameters identifier block if_statement comparison_operator identifier string string_start string_content string_end block return_statement true if_statement boolean_operator comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end integer comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end unary_operator integer block return_statement true return_statement false
Skip coordinate strings that are not valid
def truncate(self, table): if isinstance(table, (list, set, tuple)): for t in table: self._truncate(t) else: self._truncate(table)
module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier tuple identifier identifier identifier block for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier
Empty a table by deleting all of its rows.
def python_sidebar_help(python_input): token = 'class:sidebar.helptext' def get_current_description(): i = 0 for category in python_input.options: for option in category.options: if i == python_input.selected_option_index: return option.description i += 1 return '' def get_help_text(): return [(token, get_current_description())] return ConditionalContainer( content=Window( FormattedTextControl(get_help_text), style=token, height=Dimension(min=3)), filter=ShowSidebar(python_input) & Condition(lambda: python_input.show_sidebar_help) & ~is_done)
module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_content string_end function_definition identifier parameters block expression_statement assignment identifier integer for_statement identifier attribute identifier identifier block for_statement identifier attribute identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block return_statement attribute identifier identifier expression_statement augmented_assignment identifier integer return_statement string string_start string_end function_definition identifier parameters block return_statement list tuple identifier call identifier argument_list return_statement call identifier argument_list keyword_argument identifier call identifier argument_list call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier call identifier argument_list keyword_argument identifier integer keyword_argument identifier binary_operator binary_operator call identifier argument_list identifier call identifier argument_list lambda attribute identifier identifier unary_operator identifier
Create the `Layout` for the help text for the current item in the sidebar.
def _init_obo_version(self, line): if line[0:14] == "format-version": self.format_version = line[16:-1] if line[0:12] == "data-version": self.data_version = line[14:-1]
module function_definition identifier parameters identifier identifier block if_statement comparison_operator subscript identifier slice integer integer string string_start string_content string_end block expression_statement assignment attribute identifier identifier subscript identifier slice integer unary_operator integer if_statement comparison_operator subscript identifier slice integer integer string string_start string_content string_end block expression_statement assignment attribute identifier identifier subscript identifier slice integer unary_operator integer
Save obo version and release.
async def run(self): while self.eh_partition_pump.pump_status != "Errored" and not self.eh_partition_pump.is_closing(): if self.eh_partition_pump.partition_receive_handler: try: msgs = await self.eh_partition_pump.partition_receive_handler.receive( max_batch_size=self.max_batch_size, timeout=self.recieve_timeout) except Exception as e: _logger.info("Error raised while attempting to receive messages: %r", e) await self.process_error_async(e) else: if not msgs: _logger.info("No events received, queue size %r, release %r", self.eh_partition_pump.partition_receive_handler.queue_size, self.eh_partition_pump.host.eph_options.release_pump_on_timeout) if self.eh_partition_pump.host.eph_options.release_pump_on_timeout: await self.process_error_async(TimeoutError("No events received")) else: await self.process_events_async(msgs)
module function_definition identifier parameters identifier block while_statement boolean_operator comparison_operator attribute attribute identifier identifier identifier string string_start string_content string_end not_operator call attribute attribute identifier identifier identifier argument_list block if_statement attribute attribute identifier identifier identifier block try_statement block expression_statement assignment identifier await call attribute attribute attribute identifier identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement await call attribute identifier identifier argument_list identifier else_clause block if_statement not_operator identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute attribute attribute identifier identifier identifier identifier attribute attribute attribute attribute identifier identifier identifier identifier identifier if_statement attribute attribute attribute attribute identifier identifier identifier identifier identifier block expression_statement await call attribute identifier identifier argument_list call identifier argument_list string string_start string_content string_end else_clause block expression_statement await call attribute identifier identifier argument_list identifier
Runs the async partion reciever event loop to retrive messages from the event queue.
def OnTimer(self, event): self.timer_updating = True shape = self.grid.code_array.shape[:2] selection = Selection([(0, 0)], [(shape)], [], [], []) self.grid.actions.refresh_selected_frozen_cells(selection) self.grid.ForceRefresh()
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier true expression_statement assignment identifier subscript attribute attribute attribute identifier identifier identifier identifier slice integer expression_statement assignment identifier call identifier argument_list list tuple integer integer list parenthesized_expression identifier list list list expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list
Update all frozen cells because of timer call
def spawn(self, **kwargs): copy = dict(self.kwargs) copy.update(kwargs) if isinstance(self.klass, string_types): self.klass = util.import_class(self.klass) return self.klass(self.queues, self.client, **copy)
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier if_statement call identifier argument_list attribute identifier identifier identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier return_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier dictionary_splat identifier
Return a new worker for a child process
def get(self, name): "Get the first tag function matching the given name" for bucket in self: for k,v in self[bucket].items(): if k == name: return v
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end for_statement identifier identifier block for_statement pattern_list identifier identifier call attribute subscript identifier identifier identifier argument_list block if_statement comparison_operator identifier identifier block return_statement identifier
Get the first tag function matching the given name
def calc_piece_size(size, min_piece_size=20, max_piece_size=29, max_piece_count=1000): logger.debug('Calculating piece size for %i' % size) for i in range(min_piece_size, max_piece_size): if size / (2**i) < max_piece_count: break return 2**i
module function_definition identifier parameters identifier default_parameter identifier integer default_parameter identifier integer default_parameter identifier integer block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier for_statement identifier call identifier argument_list identifier identifier block if_statement comparison_operator binary_operator identifier parenthesized_expression binary_operator integer identifier identifier block break_statement return_statement binary_operator integer identifier
Calculates a good piece size for a size
def __get_switch_arr(work_sheet, row_num): u_dic = [] for col_idx in FILTER_COLUMNS: cell_val = work_sheet['{0}{1}'.format(col_idx, row_num)].value if cell_val in [1, '1']: u_dic.append(work_sheet['{0}1'.format(col_idx)].value.strip().split(',')[0]) return u_dic
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment identifier attribute subscript identifier call attribute string string_start string_content string_end identifier argument_list identifier identifier identifier if_statement comparison_operator identifier list integer string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list subscript call attribute call attribute attribute subscript identifier call attribute string string_start string_content string_end identifier argument_list identifier identifier identifier argument_list identifier argument_list string string_start string_content string_end integer return_statement identifier
if valud of the column of the row is `1`, it will be added to the array.
def promote(self, move: chess.Move) -> None: variation = self[move] i = self.variations.index(variation) if i > 0: self.variations[i - 1], self.variations[i] = self.variations[i], self.variations[i - 1]
module function_definition identifier parameters identifier typed_parameter identifier type attribute identifier identifier type none block expression_statement assignment identifier subscript identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator identifier integer block expression_statement assignment pattern_list subscript attribute identifier identifier binary_operator identifier integer subscript attribute identifier identifier identifier expression_list subscript attribute identifier identifier identifier subscript attribute identifier identifier binary_operator identifier integer
Moves a variation one up in the list of variations.
def this_year(): since = TODAY while since.month != 3 or since.day != 1: since -= delta(days=1) until = since + delta(years=1) return Date(since), Date(until)
module function_definition identifier parameters block expression_statement assignment identifier identifier while_statement boolean_operator comparison_operator attribute identifier identifier integer comparison_operator attribute identifier identifier integer block expression_statement augmented_assignment identifier call identifier argument_list keyword_argument identifier integer expression_statement assignment identifier binary_operator identifier call identifier argument_list keyword_argument identifier integer return_statement expression_list call identifier argument_list identifier call identifier argument_list identifier
Return start and end date of this fiscal year
def remove_armor(armored_data): stream = io.BytesIO(armored_data) lines = stream.readlines()[3:-1] data = base64.b64decode(b''.join(lines)) payload, checksum = data[:-3], data[-3:] assert util.crc24(payload) == checksum return payload
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier subscript call attribute identifier identifier argument_list slice integer unary_operator integer expression_statement assignment identifier call attribute identifier identifier argument_list call attribute string string_start string_end identifier argument_list identifier expression_statement assignment pattern_list identifier identifier expression_list subscript identifier slice unary_operator integer subscript identifier slice unary_operator integer assert_statement comparison_operator call attribute identifier identifier argument_list identifier identifier return_statement identifier
Decode armored data into its binary form.
def run_gui(): try: from gi.repository import Gtk except ImportError as ie: pass except RuntimeError as e: sys.stderr.write(GUI_MESSAGE) sys.stderr.write("%s: %r" % (e.__class__.__name__, utils.exc_as_decoded_string(e))) sys.stderr.flush() sys.exit(1) if not os.environ.get('DISPLAY'): sys.stderr.write("%s %s" % (GUI_MESSAGE, GUI_MESSAGE_DISPLAY)) sys.stderr.flush() sys.exit(1) try: from gi.repository import GLib GLib.set_prgname(PRGNAME) except ImportError: pass parser = argparse.ArgumentParser(description='Run DevAssistant GUI.') utils.add_no_cache_argument(parser) parser.parse_args() settings.USE_CACHE = False if '--no-cache' in sys.argv else True from devassistant.gui import main_window main_window.MainWindow()
module function_definition identifier parameters block try_statement block import_from_statement dotted_name identifier identifier dotted_name identifier except_clause as_pattern identifier as_pattern_target identifier block pass_statement except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end tuple attribute attribute identifier identifier identifier call attribute identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list integer if_statement not_operator call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end block expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list integer try_statement block import_from_statement dotted_name identifier identifier dotted_name identifier expression_statement call attribute identifier identifier argument_list identifier except_clause identifier block pass_statement expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier conditional_expression false comparison_operator string string_start string_content string_end attribute identifier identifier true import_from_statement dotted_name identifier identifier dotted_name identifier expression_statement call attribute identifier identifier argument_list
Function for running DevAssistant GUI
def getExerciseDetails(self, identifier): exercise = self._getExercise(identifier) response = { b"identifier": exercise.identifier, b"title": exercise.title, b"description": exercise.description, b"solved": exercise.wasSolvedBy(self.user) } return response
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end call attribute identifier identifier argument_list attribute identifier identifier return_statement identifier
Gets the details for a particular exercise.
def link(self, content, link, title=''): link = links.resolve(link, self._search_path, self._config.get('absolute')) return '{}{}</a>'.format( utils.make_tag('a', { 'href': link, 'title': title if title else None }), content)
module function_definition identifier parameters identifier identifier identifier default_parameter identifier string string_start string_end block expression_statement assignment identifier call attribute identifier identifier argument_list identifier attribute identifier identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end return_statement call attribute string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end conditional_expression identifier identifier none identifier
Emit a link, potentially remapped based on our embed or static rules
def dump_index(args, idx): import csv import sys from metatab import MetatabDoc doc = MetatabDoc() pack_section = doc.new_section('Packages', ['Identifier', 'Name', 'Nvname', 'Version', 'Format']) r = doc['Root'] r.new_term('Root.Title', 'Package Index') for p in idx.list(): pack_section.new_term('Package', p['url'], identifier=p['ident'], name=p['name'], nvname=p['nvname'], version=p['version'], format=p['format']) doc.write_csv(args.dump)
module function_definition identifier parameters identifier identifier block import_statement dotted_name identifier import_statement dotted_name identifier import_from_statement dotted_name identifier dotted_name identifier expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end for_statement identifier call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end subscript identifier string string_start string_content string_end keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier subscript identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list attribute identifier identifier
Create a metatab file for the index
def multi_h1(cls, a_dict: Dict[str, Any], bins=None, **kwargs) -> "HistogramCollection": from physt.binnings import calculate_bins mega_values = np.concatenate(list(a_dict.values())) binning = calculate_bins(mega_values, bins, **kwargs) title = kwargs.pop("title", None) name = kwargs.pop("name", None) collection = HistogramCollection(binning=binning, title=title, name=name) for key, value in a_dict.items(): collection.create(key, value) return collection
module function_definition identifier parameters identifier typed_parameter identifier type generic_type identifier type_parameter type identifier type identifier default_parameter identifier none dictionary_splat_pattern identifier type string string_start string_content string_end block import_from_statement dotted_name identifier identifier dotted_name identifier expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list identifier identifier dictionary_splat identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end none expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end none expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list identifier identifier return_statement identifier
Create a collection from multiple datasets.
def min_branch_length(go_id1, go_id2, godag, branch_dist): goterm1 = godag[go_id1] goterm2 = godag[go_id2] if goterm1.namespace == goterm2.namespace: dca = deepest_common_ancestor([go_id1, go_id2], godag) dca_depth = godag[dca].depth depth1 = goterm1.depth - dca_depth depth2 = goterm2.depth - dca_depth return depth1 + depth2 elif branch_dist is not None: return goterm1.depth + goterm2.depth + branch_dist
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier subscript identifier identifier expression_statement assignment identifier subscript identifier identifier if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment identifier call identifier argument_list list identifier identifier identifier expression_statement assignment identifier attribute subscript identifier identifier identifier expression_statement assignment identifier binary_operator attribute identifier identifier identifier expression_statement assignment identifier binary_operator attribute identifier identifier identifier return_statement binary_operator identifier identifier elif_clause comparison_operator identifier none block return_statement binary_operator binary_operator attribute identifier identifier attribute identifier identifier identifier
Finds the minimum branch length between two terms in the GO DAG.
def profile_path(self, path, must_exist=False): full_path = self.session.profile / path if must_exist and not full_path.exists(): raise FileNotFoundError( errno.ENOENT, os.strerror(errno.ENOENT), PurePath(full_path).name, ) return full_path
module function_definition identifier parameters identifier identifier default_parameter identifier false block expression_statement assignment identifier binary_operator attribute attribute identifier identifier identifier identifier if_statement boolean_operator identifier not_operator call attribute identifier identifier argument_list block raise_statement call identifier argument_list attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier attribute call identifier argument_list identifier identifier return_statement identifier
Return path from current profile.
def entry(): parser = argparse.ArgumentParser() parser.add_argument( 'action', help='Action to take', choices=['from_hex', 'to_rgb', 'to_hex'], ) parser.add_argument( 'value', help='Value for the action', ) parsed = parser.parse_args() if parsed.action != "from_hex": try: parsed.value = int(parsed.value) except ValueError: raise argparse.ArgumentError( "Value for this action should be an integer", ) print(globals()[parsed.action](parsed.value))
module function_definition identifier parameters block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block try_statement block expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier except_clause identifier block raise_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list call subscript call identifier argument_list attribute identifier identifier argument_list attribute identifier identifier
Parse command line arguments and run utilities.
def _validate_optional_key(key, missing, value, validated, optional): try: validated[key] = optional[key](value) except NotValid as ex: return ['%r: %s' % (key, arg) for arg in ex.args] if key in missing: missing.remove(key) return []
module function_definition identifier parameters identifier identifier identifier identifier identifier block try_statement block expression_statement assignment subscript identifier identifier call subscript identifier identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block return_statement list_comprehension binary_operator string string_start string_content string_end tuple identifier identifier for_in_clause identifier attribute identifier identifier if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement list
Validate an optional key.
def updateTitle(self): title = 'Auto Parameters ({})'.format(self.paramList.model().rowCount()) self.titleChange.emit(title) self.setWindowTitle(title)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier
Updates the Title of this widget according to how many parameters are currently in the model
def merge_cameras(self): combined = CaseInsensitiveDict({}) for sync in self.sync: combined = merge_dicts(combined, self.sync[sync].cameras) return combined
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list dictionary for_statement identifier attribute identifier identifier block expression_statement assignment identifier call identifier argument_list identifier attribute subscript attribute identifier identifier identifier identifier return_statement identifier
Merge all sync camera dicts into one.
def vm_info(name, quiet=False): data = query(quiet=True) return _find_vm(name, data, quiet)
module function_definition identifier parameters identifier default_parameter identifier false block expression_statement assignment identifier call identifier argument_list keyword_argument identifier true return_statement call identifier argument_list identifier identifier identifier
Return the information on the named VM
def rsdl(self): diff = self.Xf - self.Yfprv return sl.rfl2norm2(diff, self.X.shape, axis=self.cri.axisN)
module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator attribute identifier identifier attribute identifier identifier return_statement call attribute identifier identifier argument_list identifier attribute attribute identifier identifier identifier keyword_argument identifier attribute attribute identifier identifier identifier
Compute fixed point residual in Fourier domain.
def _metrics_get_endpoints(options): if bool(options.start) ^ bool(options.end): log.error('--start and --end must be specified together') sys.exit(1) if options.start and options.end: start = options.start end = options.end else: end = datetime.utcnow() start = end - timedelta(options.days) return start, end
module function_definition identifier parameters identifier block if_statement binary_operator call identifier argument_list attribute identifier identifier call identifier argument_list attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list integer if_statement boolean_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier binary_operator identifier call identifier argument_list attribute identifier identifier return_statement expression_list identifier identifier
Determine the start and end dates based on user-supplied options.
def add_metadata(file_name, title, artist, album): tags = EasyMP3(file_name) if title: tags["title"] = title if artist: tags["artist"] = artist if album: tags["album"] = album tags.save() return file_name
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement identifier block expression_statement assignment subscript identifier string string_start string_content string_end identifier if_statement identifier block expression_statement assignment subscript identifier string string_start string_content string_end identifier if_statement identifier block expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list return_statement identifier
As the method name suggests
def new_encoded_stream(args, stream): if args.ascii_print: return wpull.util.ASCIIStreamWriter(stream) else: return stream
module function_definition identifier parameters identifier identifier block if_statement attribute identifier identifier block return_statement call attribute attribute identifier identifier identifier argument_list identifier else_clause block return_statement identifier
Return a stream writer.
def _clean_dict(row): row_cleaned = {} for key, val in row.items(): if val is None or val == '': row_cleaned[key] = None else: row_cleaned[key] = val return row_cleaned
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement boolean_operator comparison_operator identifier none comparison_operator identifier string string_start string_end block expression_statement assignment subscript identifier identifier none else_clause block expression_statement assignment subscript identifier identifier identifier return_statement identifier
Transform empty strings values of dict `row` to None.
def cleanup(config=None, path=None): if config is None: config = parse() if path is None: path = os.getcwd() root = config.get('root', 'path') root = os.path.join(path, root) if sys.path[0] == root: sys.path.remove(root)
module function_definition identifier parameters default_parameter identifier none default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier if_statement comparison_operator subscript attribute identifier identifier integer identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Cleanup by removing paths added during earlier in configuration.
def download(self, storagemodel:object, modeldefinition = None): if (storagemodel.name is None): raise AzureStorageWrapException(storagemodel, "StorageBlobModel does not contain content nor content settings") else: container_name = modeldefinition['container'] blob_name = storagemodel.name try: if modeldefinition['blobservice'].exists(container_name, blob_name): blob = modeldefinition['blobservice'].get_blob_to_bytes( container_name=modeldefinition['container'], blob_name=storagemodel.name ) storagemodel.__mergeblob__(blob) except Exception as e: msg = 'can not load blob from container {} because {!s}'.format(storagemodel._containername, e) raise AzureStorageWrapException(storagemodel, msg=msg) return storagemodel
module function_definition identifier parameters identifier typed_parameter identifier type identifier default_parameter identifier none block if_statement parenthesized_expression comparison_operator attribute identifier identifier none block raise_statement call identifier argument_list identifier string string_start string_content string_end else_clause block expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier attribute identifier identifier try_statement block if_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list identifier identifier block expression_statement assignment identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier identifier raise_statement call identifier argument_list identifier keyword_argument identifier identifier return_statement identifier
load blob from storage into StorageBlobModelInstance
def _set_defaults(self, defaults): self.n_res = defaults.n_res self.n_sub = defaults.n_sub self.randomize = defaults.randomize self.return_median = defaults.return_median self.efficient = defaults.efficient self.return_only_bw = defaults.return_only_bw self.n_jobs = defaults.n_jobs
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier
Sets the default values for the efficient estimation
def rpc_get_name_DID(self, name, **con_info): did_info = None if check_name(name): did_info = self.get_name_DID_info(name) elif check_subdomain(name): did_info = self.get_subdomain_DID_info(name) else: return {'error': 'Invalid name or subdomain', 'http_status': 400} if did_info is None: return {'error': 'No DID for this name', 'http_status': 404} did = make_DID(did_info['name_type'], did_info['address'], did_info['index']) return self.success_response({'did': did})
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block expression_statement assignment identifier none if_statement call identifier argument_list identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier elif_clause call identifier argument_list identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier else_clause block return_statement dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end integer if_statement comparison_operator identifier none block return_statement dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end integer expression_statement assignment identifier call identifier argument_list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end return_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end identifier
Given a name or subdomain, return its DID.
def copy(self, overrides=None, locked=False): other = copy.copy(self) if overrides is not None: other.overrides = overrides other.locked = locked other._uncache() return other
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier false block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list return_statement identifier
Create a separate copy of this config.
def count(self) -> int: counter = 0 for pool in self._host_pools.values(): counter += pool.count() return counter
module function_definition identifier parameters identifier type identifier block expression_statement assignment identifier integer for_statement identifier call attribute attribute identifier identifier identifier argument_list block expression_statement augmented_assignment identifier call attribute identifier identifier argument_list return_statement identifier
Return number of connections.
def _addrs2nodes(addrs, G): for i, n in enumerate(G.nodes()): G.node[n]['addr'] = addrs[i]
module function_definition identifier parameters identifier identifier block for_statement pattern_list identifier identifier call identifier argument_list call attribute identifier identifier argument_list block expression_statement assignment subscript subscript attribute identifier identifier identifier string string_start string_content string_end subscript identifier identifier
Map agent addresses to nodes in the graph.
def visit_constant(self, node, parent): return nodes.Const( node.value, getattr(node, "lineno", None), getattr(node, "col_offset", None), parent, )
module function_definition identifier parameters identifier identifier identifier block return_statement call attribute identifier identifier argument_list attribute identifier identifier call identifier argument_list identifier string string_start string_content string_end none call identifier argument_list identifier string string_start string_content string_end none identifier
visit a Constant node by returning a fresh instance of Const
def child(self): return self.stream.directory[self.child_id] \ if self.child_id != NOSTREAM else None
module function_definition identifier parameters identifier block return_statement conditional_expression subscript attribute attribute identifier identifier identifier attribute identifier identifier line_continuation comparison_operator attribute identifier identifier identifier none
Root entry object has only one child entry and no siblings.
def getpaths(self,libname): if os.path.isabs(libname): yield libname else: for path in self.getplatformpaths(libname): yield path path = ctypes.util.find_library(libname) if path: yield path
module function_definition identifier parameters identifier identifier block if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement yield identifier else_clause block for_statement identifier call attribute identifier identifier argument_list identifier block expression_statement yield identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement identifier block expression_statement yield identifier
Return a list of paths where the library might be found.
def execute(cls, stage, state, data, next_allowed_exec_time=None): try: context = Context.from_state(state, stage) now = datetime.utcnow() if next_allowed_exec_time and now < next_allowed_exec_time: Queue.queue(stage, state, data, delay=next_allowed_exec_time) elif context.crawler.disabled: pass elif context.stage.rate_limit: try: with rate_limiter(context): context.execute(data) except RateLimitException: delay = max(1, 1.0/context.stage.rate_limit) delay = random.randint(1, int(delay)) context.log.info( "Rate limit exceeded, delaying %d sec.", delay ) Queue.queue(stage, state, data, delay=delay) else: context.execute(data) except Exception: log.exception("Task failed to execute:") finally: Queue.decr_pending(context.crawler) if not context.crawler.is_running: context.crawler.aggregate(context)
module function_definition identifier parameters identifier identifier identifier identifier default_parameter identifier none block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list if_statement boolean_operator identifier comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier identifier keyword_argument identifier identifier elif_clause attribute attribute identifier identifier identifier block pass_statement elif_clause attribute attribute identifier identifier identifier block try_statement block with_statement with_clause with_item call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier except_clause identifier block expression_statement assignment identifier call identifier argument_list integer binary_operator float attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list integer call identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier identifier identifier keyword_argument identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier except_clause identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end finally_clause block expression_statement call attribute identifier identifier argument_list attribute identifier identifier if_statement not_operator attribute attribute identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Execute the operation, rate limiting allowing.
def delete_gauge(self, slug): key = self._gauge_key(slug) self.r.delete(key) self.r.srem(self._gauge_slugs_key, slug)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier
Removes all gauges with the given ``slug``.
def _add_world_state(self, global_state: GlobalState): for hook in self._add_world_state_hooks: try: hook(global_state) except PluginSkipWorldState: return self.open_states.append(global_state.world_state)
module function_definition identifier parameters identifier typed_parameter identifier type identifier block for_statement identifier attribute identifier identifier block try_statement block expression_statement call identifier argument_list identifier except_clause identifier block return_statement expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier
Stores the world_state of the passed global state in the open states
def on_button(callback, args=(), buttons=(LEFT, MIDDLE, RIGHT, X, X2), types=(UP, DOWN, DOUBLE)): if not isinstance(buttons, (tuple, list)): buttons = (buttons,) if not isinstance(types, (tuple, list)): types = (types,) def handler(event): if isinstance(event, ButtonEvent): if event.event_type in types and event.button in buttons: callback(*args) _listener.add_handler(handler) return handler
module function_definition identifier parameters identifier default_parameter identifier tuple default_parameter identifier tuple identifier identifier identifier identifier identifier default_parameter identifier tuple identifier identifier identifier block if_statement not_operator call identifier argument_list identifier tuple identifier identifier block expression_statement assignment identifier tuple identifier if_statement not_operator call identifier argument_list identifier tuple identifier identifier block expression_statement assignment identifier tuple identifier function_definition identifier parameters identifier block if_statement call identifier argument_list identifier identifier block if_statement boolean_operator comparison_operator attribute identifier identifier identifier comparison_operator attribute identifier identifier identifier block expression_statement call identifier argument_list list_splat identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Invokes `callback` with `args` when the specified event happens.
def adjustFiles(rec, op): if isinstance(rec, MutableMapping): if rec.get("class") == "File": rec["path"] = op(rec["path"]) for d in rec: adjustFiles(rec[d], op) if isinstance(rec, MutableSequence): for d in rec: adjustFiles(d, op)
module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier identifier block if_statement comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end block expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list subscript identifier string string_start string_content string_end for_statement identifier identifier block expression_statement call identifier argument_list subscript identifier identifier identifier if_statement call identifier argument_list identifier identifier block for_statement identifier identifier block expression_statement call identifier argument_list identifier identifier
Apply a mapping function to each File path in the object `rec`.
def save_to_json(self): requestvalues = { 'DatasetId': self.dataset, 'Name': self.name, 'Description': self.description, 'Source': self.source, 'PubDate': self.publication_date, 'AccessedOn': self.accessed_on, 'Url': self.dataset_ref, 'UploadFormatType': self.upload_format_type, 'Columns': self.columns, 'FileProperty': self.file_property.__dict__, 'FlatDSUpdateOptions': self.flat_ds_update_options, 'Public': self.public } return json.dumps(requestvalues)
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute attribute identifier identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier return_statement call attribute identifier identifier argument_list identifier
The method saves DatasetUpload to json from object
def build_object(self, obj): if not obj.exclude_from_static: super(ShowPage, self).build_object(obj)
module function_definition identifier parameters identifier identifier block if_statement not_operator attribute identifier identifier block expression_statement call attribute call identifier argument_list identifier identifier identifier argument_list identifier
Override django-bakery to skip pages marked exclude_from_static
def print_help(self, file=None): output = file or self.stderr CustomStderrOptionParser.print_help(self, output) output.write("\nCommands:\n") for command_def in self.command_definitions.values(): command_def.opt_parser.print_help(output) output.write("\n")
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier boolean_operator identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence escape_sequence string_end for_statement identifier call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end
recursively call all command parsers' helps
def get(self, url, params=None, raw=False, stream=False, **request_kwargs): full_url = self.build_url(url) params = params or {} if self._token: params.setdefault('token', self._token) response = requests.get(full_url, params=params, stream=stream, **request_kwargs) self.check_for_errors(response) if stream: return response if raw or not response.content: return response.content return json.loads(response.text)
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier false default_parameter identifier false dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier boolean_operator identifier dictionary if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier dictionary_splat identifier expression_statement call attribute identifier identifier argument_list identifier if_statement identifier block return_statement identifier if_statement boolean_operator identifier not_operator attribute identifier identifier block return_statement attribute identifier identifier return_statement call attribute identifier identifier argument_list attribute identifier identifier
GET request to AmigoCloud endpoint.
def __get_package_manager(self): package_manager = "" args = "" sudo_required = True if system.is_osx(): package_manager = "brew" sudo_required = False args = " install" elif system.is_debian(): package_manager = "apt-get" args = " -y install" elif system.is_fedora(): package_manager = "yum" args = " install" elif system.is_arch(): package_manager = "pacman" args = " --noconfirm -S" if lib.which(package_manager) is None: self.logger.warn("Package manager %s not installed! Packages will not be installed." % package_manager) self.package_manager = None self.package_manager = package_manager self.sudo_required = sudo_required self.args = args
module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_end expression_statement assignment identifier string string_start string_end expression_statement assignment identifier true if_statement call attribute identifier identifier argument_list block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier false expression_statement assignment identifier string string_start string_content string_end elif_clause call attribute identifier identifier argument_list block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end elif_clause call attribute identifier identifier argument_list block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end elif_clause call attribute identifier identifier argument_list block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end if_statement comparison_operator call attribute identifier identifier argument_list identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier
Installs and verifies package manager
def returner(ret): consistency_level = getattr(pycassa.ConsistencyLevel, __opts__['cassandra.consistency_level']) pool = pycassa.ConnectionPool(__opts__['cassandra.keyspace'], __opts__['cassandra.servers']) ccf = pycassa.ColumnFamily(pool, __opts__['cassandra.column_family'], write_consistency_level=consistency_level) columns = {'fun': ret['fun'], 'id': ret['id']} if isinstance(ret['return'], dict): for key, value in six.iteritems(ret['return']): columns['return.{0}'.format(key)] = six.text_type(value) else: columns['return'] = six.text_type(ret['return']) log.debug(columns) ccf.insert(ret['jid'], columns)
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier subscript identifier string string_start string_content string_end keyword_argument identifier identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end subscript identifier string string_start string_content string_end pair string string_start string_content string_end subscript identifier string string_start string_content string_end if_statement call identifier argument_list subscript identifier string string_start string_content string_end identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end block expression_statement assignment subscript identifier call attribute string string_start string_content string_end identifier argument_list identifier call attribute identifier identifier argument_list identifier else_clause block expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end identifier
Return data to a Cassandra ColumnFamily
def load_planet_list(): planet_list = [] with open(fldr + os.sep + 'planet_samples.csv') as f: hdr = f.readline() for line in f: name, num_seeds, width, height, wind, rain, sun, lava = parse_planet_row(line) planet_list.append({'name':name, 'num_seeds':num_seeds, 'width':width, 'height':height, 'wind':wind, 'rain':rain, 'sun':sun, 'lava':lava}) return planet_list
module function_definition identifier parameters block expression_statement assignment identifier list with_statement with_clause with_item as_pattern call identifier argument_list binary_operator binary_operator identifier attribute identifier identifier string string_start string_content string_end as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list for_statement identifier identifier block expression_statement assignment pattern_list identifier identifier identifier identifier identifier identifier identifier identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier return_statement identifier
load the list of prebuilt planets
def node_inclusion_predicate_builder(nodes: Iterable[BaseEntity]) -> NodePredicate: nodes = set(nodes) @node_predicate def node_inclusion_predicate(node: BaseEntity) -> bool: return node in nodes return node_inclusion_predicate
module function_definition identifier parameters typed_parameter identifier type generic_type identifier type_parameter type identifier type identifier block expression_statement assignment identifier call identifier argument_list identifier decorated_definition decorator identifier function_definition identifier parameters typed_parameter identifier type identifier type identifier block return_statement comparison_operator identifier identifier return_statement identifier
Build a function that returns true for the given nodes.
def delete(self, ignore=None): ignore = ignore or [] def _delete(tree_or_filename, alias=None): if alias: yield alias, self.client.indices.delete_alias( index=list(_get_indices(tree_or_filename)), name=alias, ignore=ignore, ) for name, value in tree_or_filename.items(): if isinstance(value, dict): for result in _delete(value, alias=name): yield result else: yield name, self.client.indices.delete( index=name, ignore=ignore, ) for result in _delete(self.active_aliases): yield result
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier boolean_operator identifier list function_definition identifier parameters identifier default_parameter identifier none block if_statement identifier block expression_statement yield expression_list identifier call attribute attribute attribute identifier identifier identifier identifier argument_list keyword_argument identifier call identifier argument_list call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement call identifier argument_list identifier identifier block for_statement identifier call identifier argument_list identifier keyword_argument identifier identifier block expression_statement yield identifier else_clause block expression_statement yield expression_list identifier call attribute attribute attribute identifier identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier for_statement identifier call identifier argument_list attribute identifier identifier block expression_statement yield identifier
Yield tuple with deleted index name and responses from a client.
def write_html(self, text, image_map=None): "Parse HTML and convert it to PDF" h2p = HTML2FPDF(self, image_map) text = h2p.unescape(text) h2p.feed(text)
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier
Parse HTML and convert it to PDF
def tointerval(s): if isinstance(s, basestring): m = coord_re.search(s) if m.group('strand'): return pybedtools.create_interval_from_list([ m.group('chrom'), m.group('start'), m.group('stop'), '.', '0', m.group('strand')]) else: return pybedtools.create_interval_from_list([ m.group('chrom'), m.group('start'), m.group('stop'), ]) return s
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement call attribute identifier identifier argument_list string string_start string_content string_end block return_statement call attribute identifier identifier argument_list list call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end else_clause block return_statement call attribute identifier identifier argument_list list call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end return_statement identifier
If string, then convert to an interval; otherwise just return the input
def from_lines(pdb_file_lines, strict = True, parse_ligands = False): return PDB("\n".join(pdb_file_lines), strict = strict, parse_ligands = parse_ligands)
module function_definition identifier parameters identifier default_parameter identifier true default_parameter identifier false block return_statement call identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier
A function to replace the old constructor call where a list of the file's lines was passed in.
def setup_shiny(): name = 'shiny' def _get_shiny_cmd(port): conf = dedent( ).format( user=getpass.getuser(), port=str(port), site_dir=os.getcwd() ) f = tempfile.NamedTemporaryFile(mode='w', delete=False) f.write(conf) f.close() return ['shiny-server', f.name] return { 'command': _get_shiny_cmd, 'launcher_entry': { 'title': 'Shiny', 'icon_path': os.path.join(os.path.dirname(os.path.abspath(__file__)), 'icons', 'shiny.svg') } }
module function_definition identifier parameters block expression_statement assignment identifier string string_start string_content string_end function_definition identifier parameters identifier block expression_statement assignment identifier call attribute call identifier argument_list identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list keyword_argument identifier call identifier argument_list identifier keyword_argument identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier false expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list return_statement list string string_start string_content string_end attribute identifier identifier return_statement dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end string string_start string_content string_end
Manage a Shiny instance.
def generic_visit(self, node): super(RangeValues, self).generic_visit(node) return self.add(node, UNKNOWN_RANGE)
module function_definition identifier parameters identifier identifier block expression_statement call attribute call identifier argument_list identifier identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list identifier identifier
Other nodes are not known and range value neither.
def show_network_gateway(self, gateway_id, **_params): return self.get(self.network_gateway_path % gateway_id, params=_params)
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block return_statement call attribute identifier identifier argument_list binary_operator attribute identifier identifier identifier keyword_argument identifier identifier
Fetch a network gateway.
def _basename(station_code, fmt=None): info = _station_info(station_code) if not fmt: fmt = info['data_format'] basename = '%s.%s' % (info['url'].rsplit('/', 1)[1].rsplit('.', 1)[0], DATA_EXTENTIONS[fmt]) return basename
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier call identifier argument_list identifier if_statement not_operator identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier binary_operator string string_start string_content string_end tuple subscript call attribute subscript call attribute subscript identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end integer integer identifier argument_list string string_start string_content string_end integer integer subscript identifier identifier return_statement identifier
region, country, weather_station, station_code, data_format, url.
def recognise(self): if not isinstance(self.cube, Cube): raise ValueError("Use Solver.feed(cube) to feed the cube to solver.") result = "" for face in "LFRB": for square in self.cube.get_face(face)[0]: result += str(int(square == self.cube["U"]["U"])) if result not in algo_dict: raise ValueError("Invalid Cube, probably didn't solve F2L, or wrong input value.\nUse Solver.feed(cube) to reset the cube.") self.case = result return result
module function_definition identifier parameters identifier block if_statement not_operator call identifier argument_list attribute identifier identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier string string_start string_end for_statement identifier string string_start string_content string_end block for_statement identifier subscript call attribute attribute identifier identifier identifier argument_list identifier integer block expression_statement augmented_assignment identifier call identifier argument_list call identifier argument_list comparison_operator identifier subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end if_statement comparison_operator identifier identifier block raise_statement call identifier argument_list string string_start string_content escape_sequence string_end expression_statement assignment attribute identifier identifier identifier return_statement identifier
Recognise which is Cube's OLL case.
def word_texts(self): if not self.is_tagged(WORDS): self.tokenize_words() return [word[TEXT] for word in self[WORDS]]
module function_definition identifier parameters identifier block if_statement not_operator call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list return_statement list_comprehension subscript identifier identifier for_in_clause identifier subscript identifier identifier
The list of words representing ``words`` layer elements.
def raise_null_argument(func): def wrapper(*args, **kwargs): try: return func(*args, **kwargs) except TypeError as ex: if any(statement in ex.args[0] for statement in ['takes exactly', 'required positional argument']): raise NullArgument('Wrong number of arguments provided: ' + str(ex.args[0])) else: raise return wrapper
module function_definition identifier parameters identifier block function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block try_statement block return_statement call identifier argument_list list_splat identifier dictionary_splat identifier except_clause as_pattern identifier as_pattern_target identifier block if_statement call identifier generator_expression comparison_operator identifier subscript attribute identifier identifier integer for_in_clause identifier list string string_start string_content string_end string string_start string_content string_end block raise_statement call identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list subscript attribute identifier identifier integer else_clause block raise_statement return_statement identifier
decorator, to intercept num argument TypeError and raise as NullArgument
async def set_config(self, on=None, tholddark=None, tholdoffset=None): data = { key: value for key, value in { 'on': on, 'tholddark': tholddark, 'tholdoffset': tholdoffset, }.items() if value is not None } await self._request('put', 'sensors/{}/config'.format(self.id), json=data)
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier dictionary_comprehension pair identifier identifier for_in_clause pattern_list identifier identifier call attribute dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier identifier argument_list if_clause comparison_operator identifier none expression_statement await call attribute identifier identifier argument_list string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier keyword_argument identifier identifier
Change config of a CLIP LightLevel sensor.
def _perform_write(self, addr, data): return self._machine_controller.write(addr, data, self._x, self._y, 0)
module function_definition identifier parameters identifier identifier identifier block return_statement call attribute attribute identifier identifier identifier argument_list identifier identifier attribute identifier identifier attribute identifier identifier integer
Perform a write using the machine controller.
def parse_set(string): string = string.strip() if string: return set(string.split(",")) else: return set()
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement identifier block return_statement call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end else_clause block return_statement call identifier argument_list
Parse set from comma separated string.
def _create_skt(self): log.debug('Creating the auth socket') if ':' in self.auth_address: self.socket = socket.socket(socket.AF_INET6, socket.SOCK_STREAM) else: self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) try: self.socket.bind((self.auth_address, self.auth_port)) except socket.error as msg: error_string = 'Unable to bind (auth) to port {} on {}: {}'.format(self.auth_port, self.auth_address, msg) log.error(error_string, exc_info=True) raise BindException(error_string)
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier else_clause block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list tuple attribute identifier identifier attribute identifier identifier except_clause as_pattern attribute identifier identifier as_pattern_target identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier true raise_statement call identifier argument_list identifier
Create the authentication socket.
def check_url (aggregate): while True: try: aggregate.urlqueue.join(timeout=30) break except urlqueue.Timeout: aggregate.remove_stopped_threads() if not any(aggregate.get_check_threads()): break
module function_definition identifier parameters identifier block while_statement true block try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier integer break_statement except_clause attribute identifier identifier block expression_statement call attribute identifier identifier argument_list if_statement not_operator call identifier argument_list call attribute identifier identifier argument_list block break_statement
Helper function waiting for URL queue.
def proplist(self, rev, path=None): rev, prefix = self._maprev(rev) if path is None: return self._proplist(str(rev), None) else: path = type(self).cleanPath(_join(prefix, path)) return self._proplist(str(rev), path)
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block return_statement call attribute identifier identifier argument_list call identifier argument_list identifier none else_clause block expression_statement assignment identifier call attribute call identifier argument_list identifier identifier argument_list call identifier argument_list identifier identifier return_statement call attribute identifier identifier argument_list call identifier argument_list identifier identifier
List Subversion properties of the path
def _get_plt_data(self, hdrgos_usr): hdrgo2usrgos = self.grprobj.get_hdrgo2usrgos(hdrgos_usr) usrgos_actual = set([u for us in hdrgo2usrgos.values() for u in us]) go2obj = self.gosubdag.get_go2obj(usrgos_actual.union(hdrgo2usrgos.keys())) return hdrgo2usrgos, go2obj
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list list_comprehension identifier for_in_clause identifier call attribute identifier identifier argument_list for_in_clause identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list return_statement expression_list identifier identifier
Given User GO IDs, return their GO headers and other GO info.
def parse_opml_file(filename: str) -> OPML: root = parse_xml(filename).getroot() return _parse_opml(root)
module function_definition identifier parameters typed_parameter identifier type identifier type identifier block expression_statement assignment identifier call attribute call identifier argument_list identifier identifier argument_list return_statement call identifier argument_list identifier
Parse an OPML document from a local XML file.
async def push_stats(self): snapshot = self._make_stats() try: serialized = json.dumps(snapshot) await self._call_redis(aioredis.Redis.set, state.MANAGER_LISTENER_STATS, serialized) await self._call_redis(aioredis.Redis.expire, state.MANAGER_LISTENER_STATS, 3600) except TypeError: logger.error(__( "Listener can't serialize statistics:\n\n{}", traceback.format_exc() )) except aioredis.RedisError: logger.error(__( "Listener can't store updated statistics:\n\n{}", traceback.format_exc() ))
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement await call attribute identifier identifier argument_list attribute attribute identifier identifier identifier attribute identifier identifier identifier expression_statement await call attribute identifier identifier argument_list attribute attribute identifier identifier identifier attribute identifier identifier integer except_clause identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list string string_start string_content escape_sequence escape_sequence string_end call attribute identifier identifier argument_list except_clause attribute identifier identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list string string_start string_content escape_sequence escape_sequence string_end call attribute identifier identifier argument_list
Push current stats to Redis.
def save_rst(self, fd): from pylon.io import ReSTWriter ReSTWriter(self).write(fd)
module function_definition identifier parameters identifier identifier block import_from_statement dotted_name identifier identifier dotted_name identifier expression_statement call attribute call identifier argument_list identifier identifier argument_list identifier
Save a reStructuredText representation of the case.
def __create_header(self, command, command_string, session_id, reply_id): buf = pack('<4H', command, 0, session_id, reply_id) + command_string buf = unpack('8B' + '%sB' % len(command_string), buf) checksum = unpack('H', self.__create_checksum(buf))[0] reply_id += 1 if reply_id >= const.USHRT_MAX: reply_id -= const.USHRT_MAX buf = pack('<4H', command, checksum, session_id, reply_id) return buf + command_string
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement assignment identifier binary_operator call identifier argument_list string string_start string_content string_end identifier integer identifier identifier identifier expression_statement assignment identifier call identifier argument_list binary_operator string string_start string_content string_end binary_operator string string_start string_content string_end call identifier argument_list identifier identifier expression_statement assignment identifier subscript call identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list identifier integer expression_statement augmented_assignment identifier integer if_statement comparison_operator identifier attribute identifier identifier block expression_statement augmented_assignment identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list string string_start string_content string_end identifier identifier identifier identifier return_statement binary_operator identifier identifier
Puts a the parts that make up a packet together and packs them into a byte string
def reset(self): self.scores = torch.FloatTensor(torch.FloatStorage()) self.targets = torch.LongTensor(torch.LongStorage()) self.weights = torch.FloatTensor(torch.FloatStorage())
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list
Resets the meter with empty member variables
def _longoptl(self): res = [] for o in self.options: nm = o.long if o.argName is not None: nm += "=" res.append(nm) return res
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier attribute identifier identifier block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator attribute identifier identifier none block expression_statement augmented_assignment identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Get a list of string representations of the options in long format.
def salt_config_to_yaml(configuration, line_break='\n'): return salt.utils.yaml.safe_dump( configuration, line_break=line_break, default_flow_style=False)
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content escape_sequence string_end block return_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier false
Return a salt configuration dictionary, master or minion, as a yaml dump
def ParseMultiple(self, result_dicts): for result_dict in result_dicts: yield rdf_client.HardwareInfo( serial_number=result_dict["IdentifyingNumber"], system_manufacturer=result_dict["Vendor"])
module function_definition identifier parameters identifier identifier block for_statement identifier identifier block expression_statement yield call attribute identifier identifier argument_list keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier subscript identifier string string_start string_content string_end
Parse the WMI output to get Identifying Number.
def cancel(self, function): if function in self._callback.keys(): callback_id = self._callback[function][0] self.tk.after_cancel(callback_id) self._callback.pop(function) else: utils.error_format("Could not cancel function - it doesnt exist, it may have already run")
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier call attribute attribute identifier identifier identifier argument_list block expression_statement assignment identifier subscript subscript attribute identifier identifier identifier integer expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end
Cancel the scheduled `function` calls.