code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def map_representer(dumper, value): value = ODict(value.items()) if len(value.keys()) == 1: key = list(value.keys())[0] if key in CONVERTED_SUFFIXES: return fn_representer(dumper, key, value[key]) if key.startswith(FN_PREFIX): return fn_representer(dumper, key[4:], value[key]) return dumper.represent_mapping(TAG_MAP, value, flow_style=False)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list if_statement comparison_operator call identifier argument_list call attribute identifier identifier argument_list integer block expression_statement assignment identifier subscript call identifier argument_list call attribute identifier identifier argument_list integer if_statement comparison_operator identifier identifier block return_statement call identifier argument_list identifier identifier subscript identifier identifier if_statement call attribute identifier identifier argument_list identifier block return_statement call identifier argument_list identifier subscript identifier slice integer subscript identifier identifier return_statement call attribute identifier identifier argument_list identifier identifier keyword_argument identifier false
Deal with !Ref style function format and OrderedDict
def VCLibraries(self): if self.vc_ver >= 15.0: arch_subdir = self.pi.target_dir(x64=True) else: arch_subdir = self.pi.target_dir(hidex86=True) paths = ['Lib%s' % arch_subdir, r'ATLMFC\Lib%s' % arch_subdir] if self.vc_ver >= 14.0: paths += [r'Lib\store%s' % arch_subdir] return [os.path.join(self.si.VCInstallDir, path) for path in paths]
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier float block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier true else_clause block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier true expression_statement assignment identifier list binary_operator string string_start string_content string_end identifier binary_operator string string_start string_content string_end identifier if_statement comparison_operator attribute identifier identifier float block expression_statement augmented_assignment identifier list binary_operator string string_start string_content string_end identifier return_statement list_comprehension call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier identifier for_in_clause identifier identifier
Microsoft Visual C++ & Microsoft Foundation Class Libraries
def _prune_invalid_time_reductions(spec): valid_reductions = [] if not spec['var'].def_time and spec['dtype_out_time'] is not None: for reduction in spec['dtype_out_time']: if reduction not in _TIME_DEFINED_REDUCTIONS: valid_reductions.append(reduction) else: msg = ("Var {0} has no time dimension " "for the given time reduction " "{1} so this calculation will " "be skipped".format(spec['var'].name, reduction)) logging.info(msg) else: valid_reductions = spec['dtype_out_time'] return valid_reductions
module function_definition identifier parameters identifier block expression_statement assignment identifier list if_statement boolean_operator not_operator attribute subscript identifier string string_start string_content string_end identifier comparison_operator subscript identifier string string_start string_content string_end none block for_statement identifier subscript identifier string string_start string_content string_end block if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement assignment identifier parenthesized_expression call attribute concatenated_string 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 identifier argument_list attribute subscript identifier string string_start string_content string_end identifier identifier expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement assignment identifier subscript identifier string string_start string_content string_end return_statement identifier
Prune time reductions of spec with no time dimension.
def _split_after_delimiter(self, item, indent_amt): self._delete_whitespace() if self.fits_on_current_line(item.size): return last_space = None for item in reversed(self._lines): if ( last_space and (not isinstance(item, Atom) or not item.is_colon) ): break else: last_space = None if isinstance(item, self._Space): last_space = item if isinstance(item, (self._LineBreak, self._Indent)): return if not last_space: return self.add_line_break_at(self._lines.index(last_space), indent_amt)
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list if_statement call attribute identifier identifier argument_list attribute identifier identifier block return_statement expression_statement assignment identifier none for_statement identifier call identifier argument_list attribute identifier identifier block if_statement parenthesized_expression boolean_operator identifier parenthesized_expression boolean_operator not_operator call identifier argument_list identifier identifier not_operator attribute identifier identifier block break_statement else_clause block expression_statement assignment identifier none if_statement call identifier argument_list identifier attribute identifier identifier block expression_statement assignment identifier identifier if_statement call identifier argument_list identifier tuple attribute identifier identifier attribute identifier identifier block return_statement if_statement not_operator identifier block return_statement expression_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier
Split the line only after a delimiter.
def do_print(filename): with open(filename) as cmake_file: body = ast.parse(cmake_file.read()) word_print = _print_details(lambda n: "{0} {1}".format(n.type, n.contents)) ast_visitor.recurse(body, while_stmnt=_print_details(), foreach=_print_details(), function_def=_print_details(), macro_def=_print_details(), if_block=_print_details(), if_stmnt=_print_details(), elseif_stmnt=_print_details(), else_stmnt=_print_details(), function_call=_print_details(lambda n: n.name), word=word_print)
module function_definition identifier parameters identifier block with_statement with_clause with_item as_pattern call identifier argument_list identifier as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list lambda lambda_parameters identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier call identifier argument_list keyword_argument identifier call identifier argument_list keyword_argument identifier call identifier argument_list keyword_argument identifier call identifier argument_list keyword_argument identifier call identifier argument_list keyword_argument identifier call identifier argument_list keyword_argument identifier call identifier argument_list keyword_argument identifier call identifier argument_list keyword_argument identifier call identifier argument_list lambda lambda_parameters identifier attribute identifier identifier keyword_argument identifier identifier
Print the AST of filename.
def cli_forms(self, *args): forms = [] missing = [] for key, item in schemastore.items(): if 'form' in item and len(item['form']) > 0: forms.append(key) else: missing.append(key) self.log('Schemata with form:', forms) self.log('Missing forms:', missing)
module function_definition identifier parameters identifier list_splat_pattern identifier block expression_statement assignment identifier list expression_statement assignment identifier list for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement boolean_operator comparison_operator string string_start string_content string_end identifier comparison_operator call identifier argument_list subscript identifier string string_start string_content string_end integer block expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier
List all available form definitions
def _handle_interrupt(self, fileno, val): val = int(val) edge = self._map_fileno_to_options[fileno]["edge"] if (edge == 'rising' and val == 0) or (edge == 'falling' and val == 1): return debounce = self._map_fileno_to_options[fileno]["debounce_timeout_s"] if debounce: t = time.time() t_last = self._map_fileno_to_options[fileno]["interrupt_last"] if t - t_last < debounce: debug("- don't start interrupt callback due to debouncing") return self._map_fileno_to_options[fileno]["interrupt_last"] = t gpio_id = self._map_fileno_to_gpioid[fileno] if gpio_id in self._map_gpioid_to_callbacks: for cb in self._map_gpioid_to_callbacks[gpio_id]: cb(gpio_id, val)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier subscript subscript attribute identifier identifier identifier string string_start string_content string_end if_statement boolean_operator parenthesized_expression boolean_operator comparison_operator identifier string string_start string_content string_end comparison_operator identifier integer parenthesized_expression boolean_operator comparison_operator identifier string string_start string_content string_end comparison_operator identifier integer block return_statement expression_statement assignment identifier subscript subscript attribute identifier identifier identifier string string_start string_content string_end if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier subscript subscript attribute identifier identifier identifier string string_start string_content string_end if_statement comparison_operator binary_operator identifier identifier identifier block expression_statement call identifier argument_list string string_start string_content string_end return_statement expression_statement assignment subscript subscript attribute identifier identifier identifier string string_start string_content string_end identifier expression_statement assignment identifier subscript attribute identifier identifier identifier if_statement comparison_operator identifier attribute identifier identifier block for_statement identifier subscript attribute identifier identifier identifier block expression_statement call identifier argument_list identifier identifier
Internally distributes interrupts to all attached callbacks
def gen_enum_completions(self, arg_name): try: for choice in self.cmdtab[self.current_command].arguments[arg_name].choices: if self.validate_completion(choice): yield Completion(choice, -len(self.unfinished_word)) except TypeError: pass
module function_definition identifier parameters identifier identifier block try_statement block for_statement identifier attribute subscript attribute subscript attribute identifier identifier attribute identifier identifier identifier identifier identifier block if_statement call attribute identifier identifier argument_list identifier block expression_statement yield call identifier argument_list identifier unary_operator call identifier argument_list attribute identifier identifier except_clause identifier block pass_statement
generates dynamic enumeration completions
def _filter_list_to_conjunction_expression(filter_list): if not isinstance(filter_list, list): raise AssertionError(u'Expected `list`, Received: {}.'.format(filter_list)) if any((not isinstance(filter_block, Filter) for filter_block in filter_list)): raise AssertionError(u'Expected list of Filter objects. Received: {}'.format(filter_list)) expression_list = [filter_block.predicate for filter_block in filter_list] return expression_list_to_conjunction(expression_list)
module function_definition identifier parameters identifier block if_statement not_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier if_statement call identifier argument_list generator_expression not_operator call identifier argument_list identifier identifier for_in_clause identifier identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier list_comprehension attribute identifier identifier for_in_clause identifier identifier return_statement call identifier argument_list identifier
Convert a list of filters to an Expression that is the conjunction of all of them.
def build_from_yamlstr(cls, yamlstr): top_dict = yaml.safe_load(yamlstr) coordsys = top_dict.pop('coordsys') output_list = [] for e_key, e_dict in sorted(top_dict.items()): if e_key == 'coordsys': continue e_dict = top_dict[e_key] e_dict['coordsys'] = coordsys output_list += cls.build_from_energy_dict(e_key, e_dict) return output_list
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier list for_statement pattern_list identifier identifier call identifier argument_list call attribute identifier identifier argument_list block if_statement comparison_operator identifier string string_start string_content string_end block continue_statement expression_statement assignment identifier subscript identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement augmented_assignment identifier call attribute identifier identifier argument_list identifier identifier return_statement identifier
Build a list of components from a yaml string
def parse_sentence(obj: dict) -> BioCSentence: sentence = BioCSentence() sentence.offset = obj['offset'] sentence.infons = obj['infons'] sentence.text = obj['text'] for annotation in obj['annotations']: sentence.add_annotation(parse_annotation(annotation)) for relation in obj['relations']: sentence.add_relation(parse_relation(relation)) return sentence
module function_definition identifier parameters typed_parameter identifier type identifier type identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment attribute identifier identifier subscript identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier subscript identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier subscript identifier string string_start string_content string_end for_statement identifier subscript identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier for_statement identifier subscript identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier return_statement identifier
Deserialize a dict obj to a BioCSentence object
def log_status(plugin, filename, status): display = ':'.join((plugin, filename)) + ' ' log.info('%s [%s]', '{:.<70}'.format(display), status)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier binary_operator call attribute string string_start string_content string_end identifier argument_list tuple identifier identifier string string_start string_content string_end expression_statement 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 identifier identifier
Properly display a migration status line
def _populateHistogram(self): try : buildHistogram.populate1DHist(self._data, self.histogram, self.minValue, self.maxValue, self.binWidth) except: if ((self._data.max() - self._data.min()) < self.binWidth): raise ValueError("In histogram1d class, the binWidth is " "greater than the data range of the array " "object.") else: raise SystemError("An error processing the array object " "information occured in the buildHistogram " "module of histogram1d.")
module function_definition identifier parameters identifier block try_statement block expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier except_clause block if_statement parenthesized_expression comparison_operator parenthesized_expression binary_operator call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list attribute identifier identifier block raise_statement call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end else_clause block raise_statement call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end
Call the C-code that actually populates the histogram
def reset_dirty_flags(self): for sm_id, sm in self.state_machines.items(): sm.marked_dirty = False
module function_definition identifier parameters identifier block for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block expression_statement assignment attribute identifier identifier false
Set all marked_dirty flags of the state machine to false.
def grow_use_function(self, depth=0): "Select either function or terminal in grow method" if depth == 0: return False if depth == self._depth: return True return np.random.random() < 0.5
module function_definition identifier parameters identifier default_parameter identifier integer block expression_statement string string_start string_content string_end if_statement comparison_operator identifier integer block return_statement false if_statement comparison_operator identifier attribute identifier identifier block return_statement true return_statement comparison_operator call attribute attribute identifier identifier identifier argument_list float
Select either function or terminal in grow method
def prepare_input(self, extracted_str): if self.options['remove_whitespace']: optimized_str = re.sub(' +', '', extracted_str) else: optimized_str = extracted_str if self.options['remove_accents']: optimized_str = unidecode(optimized_str) if self.options['lowercase']: optimized_str = optimized_str.lower() for replace in self.options['replace']: assert len(replace) == 2, 'A replace should be a list of 2 items' optimized_str = optimized_str.replace(replace[0], replace[1]) return optimized_str
module function_definition identifier parameters identifier identifier block if_statement subscript attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end identifier else_clause block expression_statement assignment identifier identifier if_statement subscript attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list identifier if_statement subscript attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list for_statement identifier subscript attribute identifier identifier string string_start string_content string_end block assert_statement comparison_operator call identifier argument_list identifier integer string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier integer subscript identifier integer return_statement identifier
Input raw string and do transformations, as set in template file.
def ask_str(msg="Enter a string", dft=None, vld=None, shw=True, blk=True, hlp=None): vld = vld or [str] return ask(msg, dft=dft, vld=vld, shw=shw, blk=blk, hlp=hlp)
module function_definition identifier parameters default_parameter identifier string string_start string_content string_end default_parameter identifier none default_parameter identifier none default_parameter identifier true default_parameter identifier true default_parameter identifier none block expression_statement assignment identifier boolean_operator identifier list identifier return_statement call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
Prompts the user for a string.
def send( self, to=None, subject=None, contents=None, attachments=None, cc=None, bcc=None, preview_only=False, headers=None, newline_to_break=True, ): self.login() recipients, msg_string = self.prepare_send( to, subject, contents, attachments, cc, bcc, headers, newline_to_break ) if preview_only: return (recipients, msg_string) return self._attempt_send(recipients, msg_string)
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier false default_parameter identifier none default_parameter identifier true block expression_statement call attribute identifier identifier argument_list expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier identifier identifier identifier identifier identifier identifier identifier if_statement identifier block return_statement tuple identifier identifier return_statement call attribute identifier identifier argument_list identifier identifier
Use this to send an email with gmail
def create_post(self, path, **kw): content = kw.pop('content', None) onefile = kw.pop('onefile', False) kw.pop('is_page', False) metadata = {} metadata.update(self.default_metadata) metadata.update(kw) makedirs(os.path.dirname(path)) if not content.endswith('\n'): content += '\n' with io.open(path, "w+", encoding="utf8") as fd: if onefile: fd.write(write_metadata(metadata, comment_wrap=False, site=self.site, compiler=self)) fd.write(content)
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block 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 false expression_statement call attribute identifier identifier argument_list string string_start string_content string_end false expression_statement assignment identifier dictionary expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier if_statement not_operator call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end block expression_statement augmented_assignment identifier string string_start string_content escape_sequence string_end with_statement with_clause with_item as_pattern call attribute identifier 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 if_statement identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier keyword_argument identifier false keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list identifier
Create a new post.
def reset(self): for proxy in list(self.dead): self.dead.remove(proxy) self.unchecked.add(proxy)
module function_definition identifier parameters identifier block for_statement identifier call identifier argument_list attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Mark all dead proxies as unchecked
def layer_iter(layers, layer_names): if use_caffe: for layer_idx, layer in enumerate(layers): layer_name = re.sub('[-/]', '_', layer_names[layer_idx]) layer_type = layer.type layer_blobs = layer.blobs yield (layer_name, layer_type, layer_blobs) else: for layer in layers: layer_name = re.sub('[-/]', '_', layer.name) layer_type = layer.type layer_blobs = layer.blobs yield (layer_name, layer_type, layer_blobs)
module function_definition identifier parameters identifier identifier block if_statement identifier block for_statement pattern_list identifier identifier call identifier argument_list identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end subscript identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement yield tuple identifier identifier identifier else_clause block for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement yield tuple identifier identifier identifier
Iterate over all layers
def setup_kojiclient(profile): opts = koji.read_config(profile) for k, v in opts.iteritems(): opts[k] = os.path.expanduser(v) if type(v) is str else v kojiclient = koji.ClientSession(opts['server'], opts=opts) kojiclient.ssl_login(opts['cert'], None, opts['serverca']) return kojiclient
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement assignment subscript identifier identifier conditional_expression call attribute attribute identifier identifier identifier argument_list identifier comparison_operator call identifier argument_list identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end none subscript identifier string string_start string_content string_end return_statement identifier
Setup koji client session
def _AbortTerminate(self): for pid, process in iter(self._processes_per_pid.items()): if not process.is_alive(): continue logger.warning('Terminating process: {0:s} (PID: {1:d}).'.format( process.name, pid)) process.terminate()
module function_definition identifier parameters identifier block for_statement pattern_list identifier identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list block if_statement not_operator call attribute identifier identifier argument_list block continue_statement expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list
Aborts all registered processes by sending a SIGTERM or equivalent.
def config(self): if not hasattr(self, '_config'): raw_config = configparser.RawConfigParser() f = self._open() if f: raw_config.readfp(f) f.close() self._config = raw_config return self._config
module function_definition identifier parameters identifier block if_statement not_operator call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier identifier return_statement attribute identifier identifier
load the passwords from the config file
def message(msg, indent=False, mtype='standard', caption=False): if caption: msg = '\n' + msg + '\n' + '-'*len(msg) + '\n' if mtype == 'warning': msg = colorlog('Warning: ' + msg, 'yellow') if mtype == 'error': msg = colorlog('Error: ' + msg, 'red') if mtype == 'debug': msg = colorlog('Debug: ' + msg, 'pink') if mtype == 'info': msg = colorlog('Info: ' + msg, 'green') if indent: msg = ' ' + msg sys.stderr.write(msg)
module function_definition identifier parameters identifier default_parameter identifier false default_parameter identifier string string_start string_content string_end default_parameter identifier false block if_statement identifier block expression_statement assignment identifier binary_operator binary_operator binary_operator binary_operator string string_start string_content escape_sequence string_end identifier string string_start string_content escape_sequence string_end binary_operator string string_start string_content string_end call identifier argument_list identifier string string_start string_content escape_sequence string_end if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list binary_operator string string_start string_content string_end identifier string string_start string_content string_end if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list binary_operator string string_start string_content string_end identifier string string_start string_content string_end if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list binary_operator string string_start string_content string_end identifier string string_start string_content string_end if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list binary_operator string string_start string_content string_end identifier string string_start string_content string_end if_statement identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Writes messages in verbose mode
def _domain_event_pmwakeup_cb(conn, domain, reason, opaque): _salt_send_domain_event(opaque, conn, domain, opaque['event'], { 'reason': 'unknown' })
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement call identifier argument_list identifier identifier identifier subscript identifier string string_start string_content string_end dictionary pair string string_start string_content string_end string string_start string_content string_end
Domain wakeup events handler
def validate_address(value): if is_bytes(value): if not is_binary_address(value): raise InvalidAddress("Address must be 20 bytes when input type is bytes", value) return if not isinstance(value, str): raise TypeError('Address {} must be provided as a string'.format(value)) if not is_hex_address(value): raise InvalidAddress("Address must be 20 bytes, as a hex string with a 0x prefix", value) if not is_checksum_address(value): if value == value.lower(): raise InvalidAddress( "Web3.py only accepts checksum addresses. " "The software that gave you this non-checksum address should be considered unsafe, " "please file it as a bug on their platform. " "Try using an ENS name instead. Or, if you must accept lower safety, " "use Web3.toChecksumAddress(lower_case_address).", value, ) else: raise InvalidAddress( "Address has an invalid EIP-55 checksum. " "After looking up the address from the original source, try again.", value, )
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier block if_statement not_operator call identifier argument_list identifier block raise_statement call identifier argument_list string string_start string_content string_end identifier return_statement if_statement not_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier if_statement not_operator call identifier argument_list identifier block raise_statement call identifier argument_list string string_start string_content string_end identifier if_statement not_operator call identifier argument_list identifier block if_statement comparison_operator identifier call attribute identifier identifier argument_list block raise_statement call identifier argument_list concatenated_string 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 identifier else_clause block raise_statement call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end identifier
Helper function for validating an address
def override_build_kwarg(workflow, k, v, platform=None): key = OrchestrateBuildPlugin.key workspace = workflow.plugin_workspace.setdefault(key, {}) override_kwargs = workspace.setdefault(WORKSPACE_KEY_OVERRIDE_KWARGS, {}) override_kwargs.setdefault(platform, {}) override_kwargs[platform][k] = v
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier dictionary expression_statement assignment identifier call attribute identifier identifier argument_list identifier dictionary expression_statement call attribute identifier identifier argument_list identifier dictionary expression_statement assignment subscript subscript identifier identifier identifier identifier
Override a build-kwarg for all worker builds
def match(pattern): regex = re.compile(pattern) def validate(value): if not regex.match(value): return e("{} does not match the pattern {}", value, pattern) return validate
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier function_definition identifier parameters identifier block if_statement not_operator call attribute identifier identifier argument_list identifier block return_statement call identifier argument_list string string_start string_content string_end identifier identifier return_statement identifier
Validates that a field value matches the regex given to this validator.
def add_exec_to_user( self, name, env, command, args, **attrs ): exec_options = { 'command': command, 'env': env, 'args': args, } exec_options.update(attrs) self.add_to_user(name=name, exec=exec_options)
module function_definition identifier parameters identifier identifier identifier identifier identifier dictionary_splat_pattern identifier block expression_statement assignment identifier 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 expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier
Add an exec option to your user.
def upper_lower_none(arg): if not arg: return arg arg = arg.strip().lower() if arg in ['upper', 'lower']: return arg raise ValueError('argument must be "upper", "lower" or None')
module function_definition identifier parameters identifier block if_statement not_operator identifier block return_statement identifier expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list if_statement comparison_operator identifier list string string_start string_content string_end string string_start string_content string_end block return_statement identifier raise_statement call identifier argument_list string string_start string_content string_end
Validate arg value as "upper", "lower", or None.
def _pred_sets_are_in_conflict(pred_set_a, pred_set_b): for pred_a, bool_a in pred_set_a: for pred_b, bool_b in pred_set_b: if pred_a is pred_b and bool_a != bool_b: return False return True
module function_definition identifier parameters identifier identifier block for_statement pattern_list identifier identifier identifier block for_statement pattern_list identifier identifier identifier block if_statement boolean_operator comparison_operator identifier identifier comparison_operator identifier identifier block return_statement false return_statement true
Find conflict in sets, return conflict if found, else None.
def _get_magnitude_scaling_term(self, C, mag): if mag < 6.75: return C["a1_lo"] + C["a2_lo"] * mag + C["a3"] *\ ((8.5 - mag) ** 2.0) else: return C["a1_hi"] + C["a2_hi"] * mag + C["a3"] *\ ((8.5 - mag) ** 2.0)
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator identifier float block return_statement binary_operator binary_operator subscript identifier string string_start string_content string_end binary_operator subscript identifier string string_start string_content string_end identifier binary_operator subscript identifier string string_start string_content string_end line_continuation parenthesized_expression binary_operator parenthesized_expression binary_operator float identifier float else_clause block return_statement binary_operator binary_operator subscript identifier string string_start string_content string_end binary_operator subscript identifier string string_start string_content string_end identifier binary_operator subscript identifier string string_start string_content string_end line_continuation parenthesized_expression binary_operator parenthesized_expression binary_operator float identifier float
Returns the magnitude scaling term defined in equation 3
def sample_list(args): if args.entity_type and args.entity: if args.entity_type == 'sample': return [ args.entity.strip() ] elif args.entity_type == 'participant': samples = _entity_paginator(args.project, args.workspace, 'sample', page_size=2000) return [ e['name'] for e in samples if e['attributes']['participant']['entityName'] == args.entity] r = fapi.get_entity(args.project, args.workspace, args.entity_type, args.entity) fapi._check_response_code(r, 200) if args.entity_type == 'pair': pair = r.json()['attributes'] samples = [ pair['case_sample'], pair['control_sample'] ] else: samples = r.json()['attributes']["samples"]['items'] return [ sample['entityName'] for sample in samples ] return __get_entities(args, "sample", page_size=2000)
module function_definition identifier parameters identifier block if_statement boolean_operator attribute identifier identifier attribute identifier identifier block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block return_statement list call attribute attribute identifier identifier identifier argument_list elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list attribute identifier identifier attribute identifier identifier string string_start string_content string_end keyword_argument identifier integer return_statement list_comprehension subscript identifier string string_start string_content string_end for_in_clause identifier identifier if_clause comparison_operator subscript subscript subscript identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier integer if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier subscript call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end else_clause block expression_statement assignment identifier subscript subscript subscript 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 return_statement list_comprehension subscript identifier string string_start string_content string_end for_in_clause identifier identifier return_statement call identifier argument_list identifier string string_start string_content string_end keyword_argument identifier integer
List samples within a container.
def post_helper(form_tag=True, edit_mode=False): helper = FormHelper() helper.form_action = '.' helper.attrs = {'data_abide': ''} helper.form_tag = form_tag fieldsets = [ Row( Column( 'text', css_class='small-12' ), ), ] if not edit_mode: fieldsets.append( Row( Column( 'threadwatch', css_class='small-12' ), ), ) fieldsets = fieldsets+[ ButtonHolderPanel( Submit('submit', _('Submit')), css_class='text-right', ), ] helper.layout = Layout(*fieldsets) return helper
module function_definition identifier parameters default_parameter identifier true default_parameter identifier false block expression_statement assignment identifier call identifier argument_list expression_statement assignment attribute identifier identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier dictionary pair string string_start string_content string_end string string_start string_end expression_statement assignment attribute identifier identifier identifier expression_statement assignment identifier list call identifier argument_list call identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end if_statement not_operator identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list call identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement assignment identifier binary_operator identifier list call identifier argument_list call identifier argument_list string string_start string_content string_end call identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier call identifier argument_list list_splat identifier return_statement identifier
Post's form layout helper
def pop(): pid = os.getpid() thread = threading.current_thread() Wdb._instances.pop((pid, thread))
module function_definition identifier parameters block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list tuple identifier identifier
Remove instance from instance list
def write(self, x): if self._new_lines: if not self._first_write: self.stream.write('\n' * self._new_lines) self.code_lineno += self._new_lines if self._write_debug_info is not None: self.debug_info.append((self._write_debug_info, self.code_lineno)) self._write_debug_info = None self._first_write = False self.stream.write(' ' * self._indentation) self._new_lines = 0 self.stream.write(x)
module function_definition identifier parameters identifier identifier block if_statement attribute identifier identifier block if_statement not_operator attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content escape_sequence string_end attribute identifier identifier expression_statement augmented_assignment attribute identifier identifier attribute identifier identifier if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list tuple attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier false expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier expression_statement assignment attribute identifier identifier integer expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Write a string into the output stream.
def fetch_album_name(self): response = get_lastfm('track.getInfo', artist=self.artist, track=self.title) if response: try: self.album = response['track']['album']['title'] logger.debug('Found album %s from lastfm', self.album) except Exception: logger.warning('Could not fetch album name for %s', self) else: logger.warning('Could not fetch album name for %s', self)
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list string string_start string_content string_end keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier if_statement identifier block try_statement block expression_statement assignment attribute identifier identifier subscript subscript subscript identifier 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 attribute identifier identifier except_clause identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier
Get the name of the album from lastfm.
def write(self, file, text, subvars={}, trim_leading_lf=True): file.write(self.substitute(text, subvars=subvars, trim_leading_lf=trim_leading_lf))
module function_definition identifier parameters identifier identifier identifier default_parameter identifier dictionary default_parameter identifier true block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier
write to a file with variable substitution
def cmd_build(conf: Config, run_tests: bool=False): build_context = BuildContext(conf) populate_targets_graph(build_context, conf) build_context.build_graph(run_tests=run_tests) build_context.write_artifacts_metadata()
module function_definition identifier parameters typed_parameter identifier type identifier typed_default_parameter identifier type identifier false block expression_statement assignment identifier call identifier argument_list identifier expression_statement call identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list
Build requested targets, and their dependencies.
async def enable(self): await self.controller.enable_user(self.username) self._user_info.disabled = False
module function_definition identifier parameters identifier block expression_statement await call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment attribute attribute identifier identifier identifier false
Re-enable this user.
def main_photo(self): if not self._main_photo: self._main_photo = self.photos_factory() return self._main_photo
module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list return_statement attribute identifier identifier
Return user's main photo.
def rowsWithin(self, bbox): 'return list of deduped rows within bbox' ret = {} for y in range(bbox.ymin, bbox.ymax+1): for x in range(bbox.xmin, bbox.xmax+1): for attr, rows in self.pixels[y][x].items(): if attr not in self.hiddenAttrs: for r in rows: ret[id(r)] = r return list(ret.values())
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier dictionary for_statement identifier call identifier argument_list attribute identifier identifier binary_operator attribute identifier identifier integer block for_statement identifier call identifier argument_list attribute identifier identifier binary_operator attribute identifier identifier integer block for_statement pattern_list identifier identifier call attribute subscript subscript attribute identifier identifier identifier identifier identifier argument_list block if_statement comparison_operator identifier attribute identifier identifier block for_statement identifier identifier block expression_statement assignment subscript identifier call identifier argument_list identifier identifier return_statement call identifier argument_list call attribute identifier identifier argument_list
return list of deduped rows within bbox
def write(self, file_handle): for k, v in self.inputs.write_values().items(): self.set('config', k, v) self.set('config', 'namespace', self.namespace) self.manifest.write(file_handle)
module function_definition identifier parameters identifier identifier block for_statement pattern_list identifier identifier call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier
write the current state to a file manifest
def _decode(frame, tab): blocks = [] while frame: length, endseq = tab[frame[0]] blocks.extend([frame[1:length], endseq]) frame = frame[length:] if blocks and len(blocks[-1]) > 0: blocks[-1] = blocks[-1][:-1] return ''.join(blocks)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list while_statement identifier block expression_statement assignment pattern_list identifier identifier subscript identifier subscript identifier integer expression_statement call attribute identifier identifier argument_list list subscript identifier slice integer identifier identifier expression_statement assignment identifier subscript identifier slice identifier if_statement boolean_operator identifier comparison_operator call identifier argument_list subscript identifier unary_operator integer integer block expression_statement assignment subscript identifier unary_operator integer subscript subscript identifier unary_operator integer slice unary_operator integer return_statement call attribute string string_start string_end identifier argument_list identifier
Decode a frame with the help of the table.
def adjust_status(info: dict) -> dict: modified_info = deepcopy(info) modified_info.update({ 'level': get_nearest_by_numeric_key(STATUS_MAP, int(info['level'])), 'level2': STATUS_MAP[99] if info['level2'] is None else get_nearest_by_numeric_key(STATUS_MAP, int(info['level2'])) }) return modified_info
module function_definition identifier parameters typed_parameter identifier type identifier type identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end call identifier argument_list identifier call identifier argument_list subscript identifier string string_start string_content string_end pair string string_start string_content string_end conditional_expression subscript identifier integer comparison_operator subscript identifier string string_start string_content string_end none call identifier argument_list identifier call identifier argument_list subscript identifier string string_start string_content string_end return_statement identifier
Apply status mapping to a raw API result.
def task_status(self, task_id): data = { 'task_ids': task_id, } return self._perform_post_request(self.task_status_endpoint, data, self.token_header)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier return_statement call attribute identifier identifier argument_list attribute identifier identifier identifier attribute identifier identifier
Find the status of a task.
def modelnumericfunctions(self): lines = Lines() lines.extend(self.solve) lines.extend(self.calculate_single_terms) lines.extend(self.calculate_full_terms) lines.extend(self.get_point_states) lines.extend(self.set_point_states) lines.extend(self.set_result_states) lines.extend(self.get_sum_fluxes) lines.extend(self.set_point_fluxes) lines.extend(self.set_result_fluxes) lines.extend(self.integrate_fluxes) lines.extend(self.reset_sum_fluxes) lines.extend(self.addup_fluxes) lines.extend(self.calculate_error) lines.extend(self.extrapolate_error) return lines
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier return_statement identifier
Numerical functions of the model class.
def _single_function_inclusion_filter_builder(func: str) -> NodePredicate: def function_inclusion_filter(_: BELGraph, node: BaseEntity) -> bool: return node.function == func return function_inclusion_filter
module function_definition identifier parameters typed_parameter identifier type identifier type identifier block function_definition identifier parameters typed_parameter identifier type identifier typed_parameter identifier type identifier type identifier block return_statement comparison_operator attribute identifier identifier identifier return_statement identifier
Build a function inclusion filter for a single function.
def write_directory (zfile, directory): for dirpath, dirnames, filenames in os.walk(directory): zfile.write(dirpath) for filename in filenames: zfile.write(os.path.join(dirpath, filename))
module function_definition identifier parameters identifier identifier block for_statement pattern_list identifier identifier identifier call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier
Write recursively all directories and filenames to zipfile instance.
def extract_presets(app_config): return { x.lower()[10:]: app_config.get(x) for x in filter(lambda x: x.startswith("SANIC_JWT"), app_config) }
module function_definition identifier parameters identifier block return_statement dictionary_comprehension pair subscript call attribute identifier identifier argument_list slice integer call attribute identifier identifier argument_list identifier for_in_clause identifier call identifier argument_list lambda lambda_parameters identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier
Pull the application's configurations for Sanic JWT
def _decode_time(self, text): if self._kp.version >= (4, 0): try: return ( datetime(year=1, month=1, day=1, tzinfo=tz.gettz('UTC')) + timedelta( seconds = struct.unpack('<Q', base64.b64decode(text))[0] ) ) except BinasciiError: return parser.parse( text, tzinfos={'UTC':tz.gettz('UTC')} ) else: return parser.parse( text, tzinfos={'UTC':tz.gettz('UTC')} )
module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute attribute identifier identifier identifier tuple integer integer block try_statement block return_statement parenthesized_expression binary_operator call identifier argument_list keyword_argument identifier integer keyword_argument identifier integer keyword_argument identifier integer keyword_argument identifier call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list keyword_argument identifier subscript call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list identifier integer except_clause identifier block return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier dictionary pair 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 identifier keyword_argument identifier dictionary pair string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end
Convert base64 time or plaintext time to datetime
def copy_global_values(data): for k, v in data['values'].items(): if not data.get(k): data[k] = v else: puts("There is both a worksheet and a " "value named '{0}'. The worksheet data " "will be preserved.".format(k)) data.pop("values", None) return data
module function_definition identifier parameters identifier block for_statement pattern_list identifier identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list block if_statement not_operator call attribute identifier identifier argument_list identifier block expression_statement assignment subscript identifier identifier identifier else_clause block expression_statement call identifier argument_list call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end none return_statement identifier
Copy values worksheet into global namespace.
def make_request(self, handle, value, timeout=DEFAULT_TIMEOUT, with_response=True): try: with self: _LOGGER.debug("Writing %s to %s with with_response=%s", codecs.encode(value, 'hex'), handle, with_response) self._conn.writeCharacteristic(handle, value, withResponse=with_response) if timeout: _LOGGER.debug("Waiting for notifications for %s", timeout) self._conn.waitForNotifications(timeout) except btle.BTLEException as ex: _LOGGER.debug("Got exception from bluepy while making a request: %s", ex) raise
module function_definition identifier parameters identifier identifier identifier default_parameter identifier identifier default_parameter identifier true block try_statement block with_statement with_clause with_item identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list identifier string string_start string_content string_end identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier keyword_argument identifier identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier except_clause as_pattern attribute identifier identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier raise_statement
Write a GATT Command without callback - not utf-8.
def definition(self, name, tags=None): def wrapper(obj): self.definition_models.append(SwaggerDefinition(name, obj, tags=tags)) return obj return wrapper
module function_definition identifier parameters identifier identifier default_parameter identifier none block function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list identifier identifier keyword_argument identifier identifier return_statement identifier return_statement identifier
Decorator to add class based definitions
def __make_request_method(self, teststep_dict, entry_json): method = entry_json["request"].get("method") if not method: logging.exception("method missed in request.") sys.exit(1) teststep_dict["request"]["method"] = method
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end if_statement not_operator 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 expression_statement assignment subscript subscript identifier string string_start string_content string_end string string_start string_content string_end identifier
parse HAR entry request method, and make teststep method.
def process(self, msg, kwargs): prefixed_dict = {} prefixed_dict['repo_vcs'] = self.bin_name prefixed_dict['repo_name'] = self.name kwargs["extra"] = prefixed_dict return msg, kwargs
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier dictionary 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 identifier return_statement expression_list identifier identifier
Add additional context information for loggers.
def read_all(self, count=-1): res = [] while count != 0: count -= 1 p = self.read_packet() if p is None: break res.append(p) return res
module function_definition identifier parameters identifier default_parameter identifier unary_operator integer block expression_statement assignment identifier list while_statement comparison_operator identifier integer block expression_statement augmented_assignment identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier none block break_statement expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
return a list of all packets in the pcap file
def to_python(self, value): if value in self.empty_values: try: return self.empty_value except AttributeError: return u'' return bleach.clean(value, **self.bleach_options)
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block try_statement block return_statement attribute identifier identifier except_clause identifier block return_statement string string_start string_end return_statement call attribute identifier identifier argument_list identifier dictionary_splat attribute identifier identifier
Strips any dodgy HTML tags from the input
def _get_data_from_dataframe(source, fields='*', first_row=0, count=-1, schema=None): if schema is None: schema = google.datalab.bigquery.Schema.from_data(source) fields = get_field_list(fields, schema) rows = [] if count < 0: count = len(source.index) df_slice = source.reset_index(drop=True)[first_row:first_row + count] for index, data_frame_row in df_slice.iterrows(): row = data_frame_row.to_dict() for key in list(row.keys()): val = row[key] if isinstance(val, pandas.Timestamp): row[key] = val.to_pydatetime() rows.append({'c': [{'v': row[c]} if c in row else {} for c in fields]}) cols = _get_cols(fields, schema) return {'cols': cols, 'rows': rows}, len(source)
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end default_parameter identifier integer default_parameter identifier unary_operator integer default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute attribute attribute attribute identifier identifier identifier identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier list if_statement comparison_operator identifier integer block expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier subscript call attribute identifier identifier argument_list keyword_argument identifier true slice identifier binary_operator identifier identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list for_statement identifier call identifier argument_list call attribute identifier identifier argument_list block expression_statement assignment identifier subscript identifier identifier if_statement call identifier argument_list identifier attribute identifier identifier block expression_statement assignment subscript identifier identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end list_comprehension conditional_expression dictionary pair string string_start string_content string_end subscript identifier identifier comparison_operator identifier identifier dictionary for_in_clause identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier return_statement expression_list dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier call identifier argument_list identifier
Helper function for _get_data that handles Pandas DataFrames.
def invalidate(self): for row in self.rows: for key in row.keys: key.state = 0
module function_definition identifier parameters identifier block for_statement identifier attribute identifier identifier block for_statement identifier attribute identifier identifier block expression_statement assignment attribute identifier identifier integer
Rests all keys states.
def cli(ctx, all, top, nostyle, nowarn, warn, project_dir): exit_code = SCons(project_dir).lint({ 'all': all, 'top': top, 'nostyle': nostyle, 'nowarn': nowarn, 'warn': warn }) ctx.exit(exit_code)
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier identifier block expression_statement assignment identifier call attribute call identifier argument_list 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 expression_statement call attribute identifier identifier argument_list identifier
Lint the verilog code.
def _make_command_filename(self, exe): outfn = os.path.join(self.commons['cmddir'], self.name(), self._mangle_command(exe)) if os.path.exists(outfn): inc = 2 while True: newfn = "%s_%d" % (outfn, inc) if not os.path.exists(newfn): outfn = newfn break inc += 1 return outfn
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list subscript attribute identifier identifier string string_start string_content string_end call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement assignment identifier integer while_statement true block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple identifier identifier if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement assignment identifier identifier break_statement expression_statement augmented_assignment identifier integer return_statement identifier
The internal function to build up a filename based on a command.
def rlmb_base_sv2p(): hparams = rlmb_base() hparams.learning_rate_bump = 1.0 hparams.generative_model = "next_frame_sv2p" hparams.generative_model_params = "next_frame_sv2p_atari" return hparams
module function_definition identifier parameters block expression_statement assignment identifier call identifier argument_list expression_statement assignment attribute identifier identifier float expression_statement assignment attribute identifier identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier string string_start string_content string_end return_statement identifier
Base setting with sv2p as world model.
def build(): try: cloud_config = CloudConfig() config_data = cloud_config.config_data('cluster') cloud_init = CloudInit() print(cloud_init.build(config_data)) except CloudComposeException as ex: print(ex)
module function_definition identifier parameters block try_statement block 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 expression_statement assignment identifier call identifier argument_list expression_statement call identifier argument_list call attribute identifier identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call identifier argument_list identifier
builds the cloud_init script
def groff2man(data): width = get_width() cmd = 'groff -t -Tascii -m man -rLL=%dn -rLT=%dn' % (width, width) handle = subprocess.Popen( cmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) man_text, stderr = handle.communicate(data) return man_text
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier binary_operator string string_start string_content string_end tuple identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier true keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier return_statement identifier
Read groff-formatted text and output man pages.
def add_material(self, material): if self.has_material(material): return self.materials.append(material)
module function_definition identifier parameters identifier identifier block if_statement call attribute identifier identifier argument_list identifier block return_statement expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Add a material to the mesh, IF it's not already present.
def section_branch_orders(neurites, neurite_type=NeuriteType.all): return map_sections(sectionfunc.branch_order, neurites, neurite_type=neurite_type)
module function_definition identifier parameters identifier default_parameter identifier attribute identifier identifier block return_statement call identifier argument_list attribute identifier identifier identifier keyword_argument identifier identifier
section branch orders in a collection of neurites
def get(self, template_name): template = db.Template.find_one(template_name=template_name) if not template: return self.make_response('No such template found', HTTP.NOT_FOUND) return self.make_response({'template': template})
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier if_statement not_operator identifier block return_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier return_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end identifier
Get a specific template
def open(self): try: self.project.open_main(self.filename) except UnicodeDecodeError: with open(self.filename, 'rb') as openfile: encoding = get_encoding(openfile.read()) try: self.project.open_main(self.filename, encoding) except UnicodeDecodeError: LOGGER.error("'%s' encountered a fatal encoding error", self.filename) sys.exit(1) except: open_error(self.filename) except: open_error(self.filename)
module function_definition identifier parameters identifier block try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier except_clause identifier block with_statement with_clause with_item as_pattern call identifier argument_list attribute identifier identifier string string_start string_content string_end as_pattern_target identifier block expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier except_clause identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement call attribute identifier identifier argument_list integer except_clause block expression_statement call identifier argument_list attribute identifier identifier except_clause block expression_statement call identifier argument_list attribute identifier identifier
Open the subtitle file into an Aeidon project.
def available_actions(self, obs): available_actions = set() hide_specific_actions = self._agent_interface_format.hide_specific_actions for i, func in six.iteritems(actions.FUNCTIONS_AVAILABLE): if func.avail_fn(obs): available_actions.add(i) for a in obs.abilities: if a.ability_id not in actions.ABILITY_IDS: logging.warning("Unknown ability %s seen as available.", a.ability_id) continue for func in actions.ABILITY_IDS[a.ability_id]: if func.function_type in actions.POINT_REQUIRED_FUNCS[a.requires_point]: if func.general_id == 0 or not hide_specific_actions: available_actions.add(func.id) if func.general_id != 0: for general_func in actions.ABILITY_IDS[func.general_id]: if general_func.function_type is func.function_type: available_actions.add(general_func.id) break return list(available_actions)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier attribute attribute identifier identifier identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list attribute identifier identifier block if_statement call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier for_statement identifier attribute identifier identifier block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier continue_statement for_statement identifier subscript attribute identifier identifier attribute identifier identifier block if_statement comparison_operator attribute identifier identifier subscript attribute identifier identifier attribute identifier identifier block if_statement boolean_operator comparison_operator attribute identifier identifier integer not_operator identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier if_statement comparison_operator attribute identifier identifier integer block for_statement identifier subscript attribute identifier identifier attribute identifier identifier block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier break_statement return_statement call identifier argument_list identifier
Return the list of available action ids.
def run(self): self.logger.debug(f'Running command: {self.cmd}') def execute(cmd): output = "" popen = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True, shell=True) for stdout_line in iter(popen.stdout.readline, ""): stdout_line = stdout_line.strip('\n') output += stdout_line yield stdout_line popen.stdout.close() return_code = popen.wait() if return_code: raise subprocess.CalledProcessError(return_code, cmd, output) try: for out in execute(self.cmd): self.logger.info(out) return "", 0 except subprocess.CalledProcessError as e: return e.output, e.returncode
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content interpolation attribute identifier identifier string_end function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier true keyword_argument identifier true for_statement identifier call identifier argument_list attribute attribute identifier identifier identifier string string_start string_end block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end expression_statement augmented_assignment identifier identifier expression_statement yield identifier expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list if_statement identifier block raise_statement call attribute identifier identifier argument_list identifier identifier identifier try_statement block for_statement identifier call identifier argument_list attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement expression_list string string_start string_end integer except_clause as_pattern attribute identifier identifier as_pattern_target identifier block return_statement expression_list attribute identifier identifier attribute identifier identifier
Run command and report errors to Sentry.
def timeout_keep_alive_handler(self): if not self.transport.is_closing(): event = h11.ConnectionClosed() self.conn.send(event) self.transport.close()
module function_definition identifier parameters identifier block if_statement not_operator call attribute attribute identifier identifier identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list
Called on a keep-alive connection if no new data is received after a short delay.
def make_quality_report(data): if "bcbiornaseq" not in dd.get_tools_on(data): return data upload_dir = tz.get_in(("upload", "dir"), data) report_dir = os.path.join(upload_dir, "bcbioRNASeq") safe_makedir(report_dir) quality_rmd = os.path.join(report_dir, "quality_control.Rmd") quality_html = os.path.join(report_dir, "quality_control.html") quality_rmd = rmarkdown_draft(quality_rmd, "quality_control", "bcbioRNASeq") if not file_exists(quality_html): render_rmarkdown_file(quality_rmd) return data
module function_definition identifier parameters identifier block if_statement comparison_operator string string_start string_content string_end call attribute identifier identifier argument_list identifier block return_statement identifier expression_statement assignment identifier call attribute identifier identifier argument_list tuple string string_start string_content string_end string string_start string_content string_end identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end expression_statement call identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end string string_start string_content string_end if_statement not_operator call identifier argument_list identifier block expression_statement call identifier argument_list identifier return_statement identifier
create and render the bcbioRNASeq quality report
def load_template(self, template: str) -> Template: env = dict(trim_blocks=True, lstrip_blocks=True, keep_trailing_newline=False) jinja2_ext = ".jinja2" if not template.endswith(jinja2_ext): self._log.error("Template file name must end with %s" % jinja2_ext) raise ValueError if not template[:-len(jinja2_ext)].endswith(".md"): self._log.error("Template file should be a Markdown file.") raise ValueError if not os.path.isabs(template): template = os.path.join(os.path.dirname(__file__), template) with open(template, encoding="utf-8") as fin: template_obj = Template(fin.read(), **env) template_obj.filename = template self._log.info("Loaded %s", template) return template_obj
module function_definition identifier parameters identifier typed_parameter identifier type identifier type identifier block expression_statement assignment identifier call identifier argument_list keyword_argument identifier true keyword_argument identifier true keyword_argument identifier false expression_statement assignment identifier string string_start string_content string_end if_statement not_operator call attribute identifier identifier argument_list identifier block expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end identifier raise_statement identifier if_statement not_operator call attribute subscript identifier slice unary_operator call identifier argument_list identifier identifier argument_list string string_start string_content string_end block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end raise_statement identifier if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier with_statement with_clause with_item as_pattern call identifier argument_list identifier keyword_argument identifier string string_start string_content string_end as_pattern_target identifier block expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list dictionary_splat identifier expression_statement assignment attribute identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier return_statement identifier
Load a Jinja2 template from the source directory.
def __xd_iterator_pass_on(arr, view, fun): iterations = [[None] if dim in view else list(range(arr.shape[dim])) for dim in range(arr.ndim)] passon = None for indices in itertools.product(*iterations): slicer = [slice(None) if idx is None else slice(idx, idx + 1) for idx in indices] passon = fun(scipy.squeeze(arr[slicer]), passon) return passon
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier list_comprehension conditional_expression list none comparison_operator identifier identifier call identifier argument_list call identifier argument_list subscript attribute identifier identifier identifier for_in_clause identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier none for_statement identifier call attribute identifier identifier argument_list list_splat identifier block expression_statement assignment identifier list_comprehension conditional_expression call identifier argument_list none comparison_operator identifier none call identifier argument_list identifier binary_operator identifier integer for_in_clause identifier identifier expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list subscript identifier identifier identifier return_statement identifier
Like xd_iterator, but the fun return values are always passed on to the next and only the last returned.
def send_packed_virtual_touch_event(xpos, ypos, phase, device_id, finger): message = create(protobuf.SEND_PACKED_VIRTUAL_TOUCH_EVENT_MESSAGE) event = message.inner() event.data = xpos.to_bytes(2, byteorder='little') event.data += ypos.to_bytes(2, byteorder='little') event.data += phase.to_bytes(2, byteorder='little') event.data += device_id.to_bytes(2, byteorder='little') event.data += finger.to_bytes(2, byteorder='little') return message
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list integer keyword_argument identifier string string_start string_content string_end expression_statement augmented_assignment attribute identifier identifier call attribute identifier identifier argument_list integer keyword_argument identifier string string_start string_content string_end expression_statement augmented_assignment attribute identifier identifier call attribute identifier identifier argument_list integer keyword_argument identifier string string_start string_content string_end expression_statement augmented_assignment attribute identifier identifier call attribute identifier identifier argument_list integer keyword_argument identifier string string_start string_content string_end expression_statement augmented_assignment attribute identifier identifier call attribute identifier identifier argument_list integer keyword_argument identifier string string_start string_content string_end return_statement identifier
Create a new WAKE_DEVICE_MESSAGE.
def _operator_generator(index, conj): pterm = PauliTerm('I', 0, 1.0) Zstring = PauliTerm('I', 0, 1.0) for j in range(index): Zstring = Zstring*PauliTerm('Z', j, 1.0) pterm1 = Zstring*PauliTerm('X', index, 0.5) scalar = 0.5 * conj * 1.0j pterm2 = Zstring*PauliTerm('Y', index, scalar) pterm = pterm * (pterm1 + pterm2) pterm = pterm.simplify() return pterm
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list string string_start string_content string_end integer float expression_statement assignment identifier call identifier argument_list string string_start string_content string_end integer float for_statement identifier call identifier argument_list identifier block expression_statement assignment identifier binary_operator identifier call identifier argument_list string string_start string_content string_end identifier float expression_statement assignment identifier binary_operator identifier call identifier argument_list string string_start string_content string_end identifier float expression_statement assignment identifier binary_operator binary_operator float identifier float expression_statement assignment identifier binary_operator identifier call identifier argument_list string string_start string_content string_end identifier identifier expression_statement assignment identifier binary_operator identifier parenthesized_expression binary_operator identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list return_statement identifier
Internal method to generate the appropriate operator
def _get_index_for_insert(self, key, instance): if instance == 0: index = self.keys().index(key) else: occurrence = -1 for index, k in enumerate(self.keys()): if k == key: occurrence += 1 if occurrence == instance: break if occurrence != instance: raise ValueError( ( "Cannot insert before/after the %d " "instance of the key '%s' since there are " "only %d occurences of the key" % ( instance, key, occurrence) )) return index
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator identifier integer block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list identifier else_clause block expression_statement assignment identifier unary_operator integer for_statement pattern_list identifier identifier call identifier argument_list call attribute identifier identifier argument_list block if_statement comparison_operator identifier identifier block expression_statement augmented_assignment identifier integer if_statement comparison_operator identifier identifier block break_statement if_statement comparison_operator identifier identifier block raise_statement call identifier argument_list parenthesized_expression binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end tuple identifier identifier identifier return_statement identifier
Get the index of the key to insert before or after
def validate_uses_tls_for_keystone(audit_options): section = _config_section(audit_options, 'keystone_authtoken') assert section is not None, "Missing section 'keystone_authtoken'" assert not section.get('insecure') and \ "https://" in section.get("auth_uri"), \ "TLS is not used for Keystone"
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end assert_statement comparison_operator identifier none string string_start string_content string_end assert_statement boolean_operator not_operator call attribute identifier identifier argument_list string string_start string_content string_end comparison_operator 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
Verify that TLS is used to communicate with Keystone.
def show_help(name): print('Usage: python3 {} [OPTIONS]... '.format(name)) print('ISO8583 message client') print(' -v, --verbose\t\tRun transactions verbosely') print(' -p, --port=[PORT]\t\tTCP port to connect to, 1337 by default') print(' -s, --server=[IP]\t\tIP of the ISO host to connect to, 127.0.0.1 by default') print(' -t, --terminal=[ID]\t\tTerminal ID (used in DE 41 ISO field, 10001337 by default)') print(' -m, --merchant=[ID]\t\tMerchant ID (used in DE 42 ISO field, 999999999999001 by default)') print(' -k, --terminal-key=[KEY]\t\tTerminal key (\'DEADBEEF DEADBEEF DEADBEEF DEADBEEF\' by default)') print(' -K, --master-key=[KEY]\t\Master key (\'ABABABAB CDCDCDCD EFEFEFEF AEAEAEAE\' by default)') print(' -f, --file=[file.xml]\t\tUse transaction data from the given XML-file')
module function_definition identifier parameters identifier block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list string string_start string_content escape_sequence escape_sequence string_end expression_statement call identifier argument_list string string_start string_content escape_sequence escape_sequence string_end expression_statement call identifier argument_list string string_start string_content escape_sequence escape_sequence string_end expression_statement call identifier argument_list string string_start string_content escape_sequence escape_sequence string_end expression_statement call identifier argument_list string string_start string_content escape_sequence escape_sequence string_end expression_statement call identifier argument_list string string_start string_content escape_sequence escape_sequence escape_sequence escape_sequence string_end expression_statement call identifier argument_list string string_start string_content escape_sequence escape_sequence escape_sequence string_end expression_statement call identifier argument_list string string_start string_content escape_sequence escape_sequence string_end
Show help and basic usage
def delete_and_rm_options(*args, **kwargs): def inner_decorator(f, supports_batch=True, default_enable_globs=False): f = click.option( "--recursive", "-r", is_flag=True, help="Recursively delete dirs" )(f) f = click.option( "--ignore-missing", "-f", is_flag=True, help="Don't throw errors if the file or dir is absent", )(f) f = click.option( "--star-silent", "--unsafe", "star_silent", is_flag=True, help=( 'Don\'t prompt when the trailing character is a "*".' + (" Implicit in --batch" if supports_batch else "") ), )(f) f = click.option( "--enable-globs/--no-enable-globs", is_flag=True, default=default_enable_globs, show_default=True, help=( "Enable expansion of *, ?, and [ ] characters in the last " "component of file paths, unless they are escaped with " "a preceeding backslash, \\" ), )(f) if supports_batch: f = click.option( "--batch", is_flag=True, help=( "Accept a batch of paths on stdin (i.e. run in " "batchmode). Uses ENDPOINT_ID as passed on the " "commandline. Any commandline PATH given will be used " "as a prefix to all paths given" ), )(f) return f return detect_and_decorate(inner_decorator, args, kwargs)
module function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block function_definition identifier parameters identifier default_parameter identifier true default_parameter identifier false block expression_statement assignment identifier call call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end keyword_argument identifier true keyword_argument identifier string string_start string_content string_end argument_list identifier expression_statement assignment identifier call call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end keyword_argument identifier true keyword_argument identifier string string_start string_content string_end argument_list identifier expression_statement assignment identifier call 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 keyword_argument identifier true keyword_argument identifier parenthesized_expression binary_operator string string_start string_content escape_sequence string_end parenthesized_expression conditional_expression string string_start string_content string_end identifier string string_start string_end argument_list identifier expression_statement assignment identifier call call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier true keyword_argument identifier identifier keyword_argument identifier true keyword_argument identifier parenthesized_expression concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content escape_sequence string_end argument_list identifier if_statement identifier block expression_statement assignment identifier call call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier true keyword_argument identifier parenthesized_expression concatenated_string 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 argument_list identifier return_statement identifier return_statement call identifier argument_list identifier identifier identifier
Options which apply both to `globus delete` and `globus rm`
def _wrapper_find_one(self, filter_=None, *args, **kwargs): return self.__collect.find_one(filter_, *args, **kwargs)
module function_definition identifier parameters identifier default_parameter identifier none list_splat_pattern identifier dictionary_splat_pattern identifier block return_statement call attribute attribute identifier identifier identifier argument_list identifier list_splat identifier dictionary_splat identifier
Convert record to a dict that has no key error
def process_input(self, character): func = None try: func = getattr(self, "handle_%s" % chr(character), None) except: pass if func: func()
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier none try_statement block expression_statement assignment identifier call identifier argument_list identifier binary_operator string string_start string_content string_end call identifier argument_list identifier none except_clause block pass_statement if_statement identifier block expression_statement call identifier argument_list
A subclassable method for dealing with input characters.
def cross_successors(state, last_action=None): centres, edges = state acts = sum([ [s, s.inverse(), s * 2] for s in map(Step, "RUFDRB".replace(last_action.face if last_action else "", "", 1)) ], []) for step in acts: yield step, (centres, CrossSolver._rotate(edges, step))
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment pattern_list identifier identifier identifier expression_statement assignment identifier call identifier argument_list list_comprehension list identifier call attribute identifier identifier argument_list binary_operator identifier integer for_in_clause identifier call identifier argument_list identifier call attribute string string_start string_content string_end identifier argument_list conditional_expression attribute identifier identifier identifier string string_start string_end string string_start string_end integer list for_statement identifier identifier block expression_statement yield expression_list identifier tuple identifier call attribute identifier identifier argument_list identifier identifier
Successors function for solving the cross.
def indent(text, amount, ch=' '): padding = amount * ch return ''.join(padding+line for line in text.splitlines(True))
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier binary_operator identifier identifier return_statement call attribute string string_start string_end identifier generator_expression binary_operator identifier identifier for_in_clause identifier call attribute identifier identifier argument_list true
Indents a string by the given amount of characters.
def _find_entry_call(self, frames): back_i = 0 pout_path = self._get_src_file(self.modname) for frame_i, frame in enumerate(frames): if frame[1] == pout_path: back_i = frame_i return Call(frames[back_i])
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier for_statement pattern_list identifier identifier call identifier argument_list identifier block if_statement comparison_operator subscript identifier integer identifier block expression_statement assignment identifier identifier return_statement call identifier argument_list subscript identifier identifier
attempts to auto-discover the correct frame
def check_schedule(): all_items = prefetch_schedule_items() for validator, _type, _msg in SCHEDULE_ITEM_VALIDATORS: if validator(all_items): return False all_slots = prefetch_slots() for validator, _type, _msg in SLOT_VALIDATORS: if validator(all_slots): return False return True
module function_definition identifier parameters block expression_statement assignment identifier call identifier argument_list for_statement pattern_list identifier identifier identifier identifier block if_statement call identifier argument_list identifier block return_statement false expression_statement assignment identifier call identifier argument_list for_statement pattern_list identifier identifier identifier identifier block if_statement call identifier argument_list identifier block return_statement false return_statement true
Helper routine to easily test if the schedule is valid
def extend(self, tasks): self._tasks.extend(tasks) for task in tasks: current = self.map modules = task.fullname.split('.') for module in modules[:-1]: if not isinstance(current[module], Shovel): logger.warn('Overriding task %s with a module' % current[module].file) shovel = Shovel() shovel.overrides = current[module] current[module] = shovel current = current[module].map name = modules[-1] if name in current: logger.warn('Overriding %s with %s' % ( '.'.join(modules), task.file)) task.overrides = current[name] current[name] = task
module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier for_statement identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end for_statement identifier subscript identifier slice unary_operator integer block if_statement not_operator call identifier argument_list subscript identifier identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end attribute subscript identifier identifier identifier expression_statement assignment identifier call identifier argument_list expression_statement assignment attribute identifier identifier subscript identifier identifier expression_statement assignment subscript identifier identifier identifier expression_statement assignment identifier attribute subscript identifier identifier identifier expression_statement assignment identifier subscript identifier unary_operator integer if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple call attribute string string_start string_content string_end identifier argument_list identifier attribute identifier identifier expression_statement assignment attribute identifier identifier subscript identifier identifier expression_statement assignment subscript identifier identifier identifier
Add tasks to this particular shovel
def run_container(): os.chdir(my_directory) cmd = [ 'docker', 'run', '-it', '--rm', '-v', '{}:/cauldron'.format(my_directory), '-p', '5010:5010', 'cauldron_app', '/bin/bash' ] return os.system(' '.join(cmd))
module function_definition identifier parameters block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier 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 call attribute string string_start string_content string_end identifier argument_list identifier 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 return_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier
Runs an interactive container
def visit_generatorexp(self, node): return "(%s %s)" % ( node.elt.accept(self), " ".join(n.accept(self) for n in node.generators), )
module function_definition identifier parameters identifier identifier block return_statement binary_operator string string_start string_content string_end tuple call attribute attribute identifier identifier identifier argument_list identifier call attribute string string_start string_content string_end identifier generator_expression call attribute identifier identifier argument_list identifier for_in_clause identifier attribute identifier identifier
return an astroid.GeneratorExp node as string
def touchz(self, path): self.client.write(path, data='', overwrite=False)
module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier string string_start string_end keyword_argument identifier false
To touchz using the web hdfs "write" cmd.
def search_range(self, value): if value == 0 or not value % 16: self._search_range = value else: raise InvalidSearchRangeError("Search range must be a multiple of " "16.") self._replace_bm()
module function_definition identifier parameters identifier identifier block if_statement boolean_operator comparison_operator identifier integer not_operator binary_operator identifier integer block expression_statement assignment attribute identifier identifier identifier else_clause block raise_statement call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list
Set private ``_search_range`` and reset ``_block_matcher``.
def generate_fetch_ivy(cls, jars, ivyxml, confs, resolve_hash_name): org = IvyUtils.INTERNAL_ORG_NAME name = resolve_hash_name extra_configurations = [conf for conf in confs if conf and conf != 'default'] jars_by_key = OrderedDict() for jar in jars: jars_by_key.setdefault((jar.org, jar.name, jar.rev), []).append(jar) dependencies = [cls._generate_fetch_jar_template(_jars) for _jars in jars_by_key.values()] template_data = TemplateData(org=org, module=name, extra_configurations=extra_configurations, dependencies=dependencies) template_relpath = os.path.join('templates', 'ivy_utils', 'ivy_fetch.xml.mustache') cls._write_ivy_xml_file(ivyxml, template_data, template_relpath)
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier identifier expression_statement assignment identifier list_comprehension identifier for_in_clause identifier identifier if_clause boolean_operator identifier comparison_operator identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list for_statement identifier identifier block expression_statement call attribute call attribute identifier identifier argument_list tuple attribute identifier identifier attribute identifier identifier attribute identifier identifier list identifier argument_list identifier expression_statement assignment identifier list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier expression_statement assignment identifier call attribute attribute identifier 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 expression_statement call attribute identifier identifier argument_list identifier identifier identifier
Generates an ivy xml with all jars marked as intransitive using the all conflict manager.
def find_child(sexpr: Sexpr, *tags: str) -> Optional[Sexpr]: _assert_valid_sexpr(sexpr) for child in sexpr[1:]: if _is_sexpr(child) and child[0] in tags: return child return None
module function_definition identifier parameters typed_parameter identifier type identifier typed_parameter list_splat_pattern identifier type identifier type generic_type identifier type_parameter type identifier block expression_statement call identifier argument_list identifier for_statement identifier subscript identifier slice integer block if_statement boolean_operator call identifier argument_list identifier comparison_operator subscript identifier integer identifier block return_statement identifier return_statement none
Search for a tag among direct children of the s-expression.
def _handle_authentication_error(self): response = make_response('Access Denied') response.headers['WWW-Authenticate'] = self.auth.get_authenticate_header() response.status_code = 401 return response
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list string string_start string_content string_end expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier integer return_statement identifier
Return an authentication error.
def feed(self): "Feed a line from the contents of the GPS log to the daemon." line = self.testload.sentences[self.index % len(self.testload.sentences)] if "%Delay:" in line: delay = line.split()[1] time.sleep(int(delay)) self.write(line) if self.progress: self.progress("gpsfake: %s feeds %d=%s\n" % (self.testload.name, len(line), repr(line))) time.sleep(WRITE_PAD) self.index += 1
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier subscript attribute attribute identifier identifier identifier binary_operator attribute identifier identifier call identifier argument_list attribute attribute identifier identifier identifier if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment identifier subscript call attribute identifier identifier argument_list integer expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content escape_sequence string_end tuple attribute attribute identifier identifier identifier call identifier argument_list identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement augmented_assignment attribute identifier identifier integer
Feed a line from the contents of the GPS log to the daemon.
def load(cls, path): assert os.path.exists(path), "No such file: %r" % path (folder, filename) = os.path.split(path) (name, extension) = os.path.splitext(filename) wave = Waveform(None) wave._path = path return wave
module function_definition identifier parameters identifier identifier block assert_statement call attribute attribute identifier identifier identifier argument_list identifier binary_operator string string_start string_content string_end identifier expression_statement assignment tuple_pattern identifier identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment tuple_pattern identifier identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list none expression_statement assignment attribute identifier identifier identifier return_statement identifier
Load Waveform from file.
def load(self, _from): def load_rec(inode, config): for k in config: if isinstance(config[k], dict) and \ k not in ['value', 'default']: if k in inode: load_rec(inode[k], config[k]) else: LOG.debug("+ config element: '%s'", k) else: inode[k] = config[k] with open(_from, 'r') as infile: obj = yaml.load(infile, Loader=ConfigLoader) upgrade(obj) load_rec(self.node, obj) self['config_file'] = os.path.abspath(_from)
module function_definition identifier parameters identifier identifier block function_definition identifier parameters identifier identifier block for_statement identifier identifier block if_statement boolean_operator call identifier argument_list subscript identifier identifier identifier line_continuation comparison_operator identifier list string string_start string_content string_end string string_start string_content string_end block if_statement comparison_operator identifier identifier block expression_statement call identifier argument_list subscript identifier identifier subscript identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier else_clause block expression_statement assignment subscript identifier identifier subscript 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 identifier keyword_argument identifier identifier expression_statement call identifier argument_list identifier expression_statement call identifier argument_list attribute identifier identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list identifier
Load the configuration dictionary from file.
def _count_counters(self, counter): if getattr(self, 'as_set', False): return len(set(counter)) else: return sum(counter.values())
module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier string string_start string_content string_end false block return_statement call identifier argument_list call identifier argument_list identifier else_clause block return_statement call identifier argument_list call attribute identifier identifier argument_list
Return all elements count from Counter