code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def check_user(user, password): return ((user == attowiki.user or attowiki.user is None) and (password == attowiki.password or attowiki.password is None))
module function_definition identifier parameters identifier identifier block return_statement parenthesized_expression boolean_operator parenthesized_expression boolean_operator comparison_operator identifier attribute identifier identifier comparison_operator attribute identifier identifier none parenthesized_expression boolean_operator comparison_operator identifier attribute identifier identifier comparison_operator attribute identifier identifier none
check the auth for user and password.
def read(self, length=None): if length is None: return self.reader.read() result = self.reader.read(length) if len(result) != length: raise BufferError( 'No more data left to read (need {}, got {}: {}); last read {}' .format(length, len(result), repr(result), repr(self._last)) ) self._last = result return result
module function_definition identifier parameters identifier default_parameter identifier none block if_statement comparison_operator identifier none block return_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_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 call identifier argument_list identifier call identifier argument_list identifier call identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier identifier return_statement identifier
Read the given amount of bytes.
def handle_onchain_secretreveal( target_state: TargetTransferState, state_change: ContractReceiveSecretReveal, channel_state: NettingChannelState, ) -> TransitionResult[TargetTransferState]: valid_secret = is_valid_secret_reveal( state_change=state_change, transfer_secrethash=target_state.transfer.lock.secrethash, secret=state_change.secret, ) if valid_secret: channel.register_onchain_secret( channel_state=channel_state, secret=state_change.secret, secrethash=state_change.secrethash, secret_reveal_block_number=state_change.block_number, ) target_state.state = TargetTransferState.ONCHAIN_UNLOCK target_state.secret = state_change.secret return TransitionResult(target_state, list())
module function_definition identifier parameters typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier type generic_type identifier type_parameter type identifier block expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute attribute attribute identifier identifier identifier identifier keyword_argument identifier attribute identifier identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier return_statement call identifier argument_list identifier call identifier argument_list
Validates and handles a ContractReceiveSecretReveal state change.
def clean_expired_user_attempts(attempt_time: datetime = None) -> int: if settings.AXES_COOLOFF_TIME is None: log.debug('AXES: Skipping clean for expired access attempts because no AXES_COOLOFF_TIME is configured') return 0 threshold = get_cool_off_threshold(attempt_time) count, _ = AccessAttempt.objects.filter(attempt_time__lt=threshold).delete() log.info('AXES: Cleaned up %s expired access attempts from database that were older than %s', count, threshold) return count
module function_definition identifier parameters typed_default_parameter identifier type identifier none type identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement integer expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment pattern_list identifier identifier call attribute call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier return_statement identifier
Clean expired user attempts from the database.
def inten(function): "Decorator. Attempts to convert return value to int" def wrapper(*args, **kwargs): return coerce_to_int(function(*args, **kwargs)) return wrapper
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block return_statement call identifier argument_list call identifier argument_list list_splat identifier dictionary_splat identifier return_statement identifier
Decorator. Attempts to convert return value to int
def run(self, url): url = self.process_url(url) if not url: return response = self.make_request(self.http, url) selector = self.process_response(response) entities = [] for root in self.get_roots(selector): entity = self.entity(root) entity = self.process_entity(entity) if entity: entities.append(entity) return EntityList(*entities)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement not_operator identifier block return_statement expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier list for_statement identifier call attribute identifier identifier argument_list identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement call identifier argument_list list_splat identifier
Request URL, scrape response and return an EntityList.
def accept_all(self): keys = self.list_keys() for key in keys[self.PEND]: try: shutil.move( os.path.join( self.opts['pki_dir'], self.PEND, key), os.path.join( self.opts['pki_dir'], self.ACC, key) ) eload = {'result': True, 'act': 'accept', 'id': key} self.event.fire_event(eload, salt.utils.event.tagify(prefix='key')) except (IOError, OSError): pass return self.list_keys()
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list for_statement identifier subscript identifier attribute identifier identifier block try_statement block expression_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier identifier call attribute attribute identifier identifier identifier argument_list subscript attribute identifier identifier string string_start string_content string_end attribute identifier identifier identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end true pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier call attribute attribute attribute identifier identifier identifier identifier argument_list keyword_argument identifier string string_start string_content string_end except_clause tuple identifier identifier block pass_statement return_statement call attribute identifier identifier argument_list
Accept all keys in pre
def dispatch_hook(cls, _pkt=None, *args, **kargs): cls = conf.raw_layer if _pkt is not None: ptype = orb(_pkt[0]) return globals().get(_param_set_cls.get(ptype), conf.raw_layer) return cls
module function_definition identifier parameters identifier default_parameter identifier none list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list subscript identifier integer return_statement call attribute call identifier argument_list identifier argument_list call attribute identifier identifier argument_list identifier attribute identifier identifier return_statement identifier
Returns the right parameter set class.
def focus_prev_matching(self, querystring): self.focus_property(lambda x: x._message.matches(querystring), self._tree.prev_position)
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list lambda lambda_parameters identifier call attribute attribute identifier identifier identifier argument_list identifier attribute attribute identifier identifier identifier
focus previous matching message in depth first order
def custom_prompt(msg, delims="", completer=lambda: None): try: orig_delims = readline.get_completer_delims() orig_completer = readline.get_completer() readline.set_completer_delims(delims) readline.set_completer(completer) try: ret = input(msg) finally: readline.set_completer_delims(orig_delims) readline.set_completer(orig_completer) return ret except EOFError: raise UserQuit()
module function_definition identifier parameters identifier default_parameter identifier string string_start string_end default_parameter identifier lambda none block try_statement 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 identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier try_statement block expression_statement assignment identifier call identifier argument_list identifier finally_clause block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier except_clause identifier block raise_statement call identifier argument_list
Start up a prompt that with particular delims and completer
def serialize(self, format): if PY3: return self.prov_g.serialize(format=format).decode('utf-8') else: return self.prov_g.serialize(format=format)
module function_definition identifier parameters identifier identifier block if_statement identifier block return_statement call attribute call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier identifier argument_list string string_start string_content string_end else_clause block return_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier
Serialize provenance graph in the specified format
def forget(self, label_name): self._bayes.pop(label_name) baye_dir = self._get_baye_dir(label_name) logger.info("Deleting label training {} : {}".format( label_name, baye_dir )) rm_rf(baye_dir)
module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier expression_statement call identifier argument_list identifier
Forget training for label 'label_name'
def __get_user_env_vars(self): return (os.environ.get(self.GP_URL_ENV_VAR), os.environ.get(self.GP_INSTANCE_ID_ENV_VAR), os.environ.get(self.GP_USER_ID_ENV_VAR), os.environ.get(self.GP_PASSWORD_ENV_VAR), os.environ.get(self.GP_IAM_API_KEY_ENV_VAR))
module function_definition identifier parameters identifier block return_statement tuple call attribute attribute identifier identifier identifier argument_list attribute identifier identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier
Return the user defined environment variables
def generate_transpose(node_name, in_name, out_name, axes, base_name, func_counter): trans = nnabla_pb2.Function() trans.type = "Transpose" set_function_name(trans, node_name, base_name, func_counter) trans.input.extend([in_name]) trans.output.extend([out_name]) tp = trans.transpose_param tp.axes.extend(axes) return trans
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier string string_start string_content string_end expression_statement call identifier argument_list identifier identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list list identifier expression_statement call attribute attribute identifier identifier identifier argument_list list identifier expression_statement assignment identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement identifier
Generate a Transpose operator to transpose the specified buffer.
def point(self, x, y, z=0, m=0): pointShape = _Shape(self.shapeType) pointShape.points.append([x, y, z, m]) self._shapes.append(pointShape)
module function_definition identifier parameters identifier identifier identifier default_parameter identifier integer default_parameter identifier integer block expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list list identifier identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Creates a point shape.
def edit(env, securitygroup_id, rule_id, remote_ip, remote_group, direction, ethertype, port_max, port_min, protocol): mgr = SoftLayer.NetworkManager(env.client) data = {} if remote_ip: data['remote_ip'] = remote_ip if remote_group: data['remote_group'] = remote_group if direction: data['direction'] = direction if ethertype: data['ethertype'] = ethertype if port_max is not None: data['port_max'] = port_max if port_min is not None: data['port_min'] = port_min if protocol: data['protocol'] = protocol ret = mgr.edit_securitygroup_rule(securitygroup_id, rule_id, **data) if not ret: raise exceptions.CLIAbort("Failed to edit security group rule") table = formatting.Table(REQUEST_BOOL_COLUMNS) table.add_row([ret['requestId']]) env.fout(table)
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier dictionary if_statement identifier block expression_statement assignment subscript identifier string string_start string_content string_end identifier if_statement identifier block expression_statement assignment subscript identifier string string_start string_content string_end identifier if_statement identifier block expression_statement assignment subscript identifier string string_start string_content string_end identifier if_statement identifier block expression_statement assignment subscript identifier string string_start string_content string_end identifier if_statement comparison_operator identifier none block expression_statement assignment subscript identifier string string_start string_content string_end identifier if_statement comparison_operator identifier none block expression_statement assignment subscript identifier string string_start string_content string_end identifier if_statement identifier block expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier dictionary_splat identifier if_statement not_operator identifier block raise_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list list subscript identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier
Edit a security group rule in a security group.
def close(self, signalnum=None, frame=None): self._running = False self._log_debug("Closing all tail objects") self._active = False for fid in self._tails: self._tails[fid].close() for n in range(0,self._number_of_consumer_processes): if self._proc[n] is not None and self._proc[n].is_alive(): self._logger.debug("Terminate Process: " + str(n)) self._proc[n].terminate() self._proc[n].join()
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none block expression_statement assignment attribute identifier identifier false expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier false for_statement identifier attribute identifier identifier block expression_statement call attribute subscript attribute identifier identifier identifier identifier argument_list for_statement identifier call identifier argument_list integer attribute identifier identifier block if_statement boolean_operator comparison_operator subscript attribute identifier identifier identifier none call attribute subscript attribute identifier identifier identifier identifier argument_list block expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list identifier expression_statement call attribute subscript attribute identifier identifier identifier identifier argument_list expression_statement call attribute subscript attribute identifier identifier identifier identifier argument_list
Closes all currently open Tail objects
def story_node_add_arc_element_update_characters_locations(sender, instance, created, *args, **kwargs): arc_node = ArcElementNode.objects.get(pk=instance.pk) logger.debug('Scanning arc_node %s' % arc_node) if arc_node.arc_element_type == 'root': logger.debug("root node. skipping...") else: logger.debug('Checking arc node for story element relationship...') if arc_node.story_element_node: logger.debug('Found a story element node for arc element...') story_node = arc_node.story_element_node if arc_node.assoc_characters.count() > 0: logger.debug('Found %d characters to add...' % arc_node.assoc_characters.count()) for character in arc_node.assoc_characters.all(): story_node.assoc_characters.add(character) if arc_node.assoc_locations.count() > 0: logger.debug('Found %d locations to add...' % arc_node.assoc_locations.count()) for location in arc_node.assoc_locations.all(): story_node.assoc_locations.add(location)
module function_definition identifier parameters identifier identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator call attribute attribute identifier identifier identifier argument_list integer block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list for_statement identifier call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator call attribute attribute identifier identifier identifier argument_list integer block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list for_statement identifier call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute attribute identifier identifier identifier argument_list identifier
If an arc element is added to a story element node, add any missing elements or locations.
def reset_highlights(self): for dtype in ["specimens", "samples", "sites", "locations", "ages"]: wind = self.FindWindowByName(dtype + '_btn') wind.Unbind(wx.EVT_PAINT, handler=self.highlight_button) self.Refresh() self.bSizer_msg.ShowItems(False) self.hbox.Fit(self)
module function_definition identifier parameters identifier block for_statement 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 block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list false expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Remove red outlines from all buttons
def translateDNA_6Frames(sequence) : trans = ( translateDNA(sequence, 'f1'), translateDNA(sequence, 'f2'), translateDNA(sequence, 'f3'), translateDNA(sequence, 'r1'), translateDNA(sequence, 'r2'), translateDNA(sequence, 'r3'), ) return trans
module function_definition identifier parameters identifier block expression_statement assignment identifier tuple call identifier argument_list identifier string string_start string_content string_end call identifier argument_list identifier string string_start string_content string_end call identifier argument_list identifier string string_start string_content string_end call identifier argument_list identifier string string_start string_content string_end call identifier argument_list identifier string string_start string_content string_end call identifier argument_list identifier string string_start string_content string_end return_statement identifier
returns 6 translation of sequence. One for each reading frame
def _parse_triggered_hits(self, file_obj): for _ in range(self.n_triggered_hits): dom_id, pmt_id = unpack('<ib', file_obj.read(5)) tdc_time = unpack('>I', file_obj.read(4))[0] tot = unpack('<b', file_obj.read(1))[0] trigger_mask = unpack('<Q', file_obj.read(8)) self.triggered_hits.append( (dom_id, pmt_id, tdc_time, tot, trigger_mask) )
module function_definition identifier parameters identifier identifier block for_statement identifier call identifier argument_list attribute identifier identifier block expression_statement assignment pattern_list identifier identifier call identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list integer expression_statement assignment identifier subscript call identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list integer integer expression_statement assignment identifier subscript call identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list integer integer expression_statement assignment identifier call identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list integer expression_statement call attribute attribute identifier identifier identifier argument_list tuple identifier identifier identifier identifier identifier
Parse and store triggered hits.
def create_migration(initial=False): settings = DjangoSettings() if 'south' not in (name.lower() for name in settings.INSTALLED_APPS): print("Temporarily adding 'south' into INSTALLED_APPS.") settings.INSTALLED_APPS.append('south') kwargs = dict(initial=True) if initial else dict(auto=True) run_django_cmd('schemamigration', package['name'], **kwargs)
module function_definition identifier parameters default_parameter identifier false block expression_statement assignment identifier call identifier argument_list if_statement comparison_operator string string_start string_content string_end generator_expression call attribute identifier identifier argument_list for_in_clause identifier attribute identifier identifier block expression_statement call identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier conditional_expression call identifier argument_list keyword_argument identifier true identifier call identifier argument_list keyword_argument identifier true expression_statement call identifier argument_list string string_start string_content string_end subscript identifier string string_start string_content string_end dictionary_splat identifier
Create a South migration for this project
def size(self): size = 0 try: tip = self.get_changeset() for topnode, dirs, files in tip.walk('/'): for f in files: size += tip.get_file_size(f.path) for dir in dirs: for f in files: size += tip.get_file_size(f.path) except RepositoryError: pass return size
module function_definition identifier parameters identifier block expression_statement assignment identifier integer try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list for_statement pattern_list identifier identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end block for_statement identifier identifier block expression_statement augmented_assignment identifier call attribute identifier identifier argument_list attribute identifier identifier for_statement identifier identifier block for_statement identifier identifier block expression_statement augmented_assignment identifier call attribute identifier identifier argument_list attribute identifier identifier except_clause identifier block pass_statement return_statement identifier
Returns combined size in bytes for all repository files
def _format_type(lines, element, spacer=""): rlines = [] rlines.append(element.signature) _format_summary(rlines, element) rlines.append("") _format_generic(rlines, element, ["summary"]) if len(element.executables) > 0: rlines.append("\nEMBEDDED PROCEDURES") for key, value in list(element.executables.items()): rlines.append(" {}".format(value.__str__())) target = value.target if target is not None: _format_executable(rlines, target, " ") if len(element.members) > 0: rlines.append("\nEMBEDDED MEMBERS") for key, value in list(element.members.items()): _format_value_element(rlines, value, " ") lines.extend([spacer + l for l in rlines])
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_end block expression_statement assignment identifier list expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_end expression_statement call identifier argument_list identifier identifier list string string_start string_content string_end if_statement comparison_operator call identifier argument_list attribute identifier identifier integer block expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end for_statement pattern_list identifier identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier none block expression_statement call identifier argument_list identifier identifier string string_start string_content string_end if_statement comparison_operator call identifier argument_list attribute identifier identifier integer block expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end for_statement pattern_list identifier identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list block expression_statement call identifier argument_list identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list list_comprehension binary_operator identifier identifier for_in_clause identifier identifier
Formats a derived type for full documentation output.
def clear(self): for i, value in enumerate(self.buffer): self.buffer[i] = 0
module function_definition identifier parameters identifier block for_statement pattern_list identifier identifier call identifier argument_list attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier integer
Clear contents of display buffer.
def _shutdown(self): if self._proc: ret = _shutdown_proc(self._proc, 3) logging.info("Shutdown with return code: %s", ret) self._proc = None
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier integer expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment attribute identifier identifier none
Terminate the sub-process.
def _ExtractClientIdFromPath(entry, event): match = re.match(r".*(C\.[0-9a-fA-F]{16}).*", entry.http_request_path) if match: event.client = match.group(1)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier if_statement identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list integer
Extracts a Client ID from an APIAuditEntry's HTTP request path.
def com_google_fonts_check_name_description_max_length(ttFont): failed = False for name in ttFont['name'].names: if (name.nameID == NameID.DESCRIPTION and len(name.string.decode(name.getEncoding())) > 200): failed = True break if failed: yield WARN, ("A few name table entries with ID={} (NameID.DESCRIPTION)" " are longer than 200 characters." " Please check whether those entries are copyright notices" " mistakenly stored in the description string entries by" " a bug in an old FontLab version." " If that's the case, then such copyright notices must be" " removed from these entries." "").format(NameID.DESCRIPTION) else: yield PASS, "All description name records have reasonably small lengths."
module function_definition identifier parameters identifier block expression_statement assignment identifier false for_statement identifier attribute subscript identifier string string_start string_content string_end identifier block if_statement parenthesized_expression boolean_operator comparison_operator attribute identifier identifier attribute identifier identifier comparison_operator call identifier argument_list call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list integer block expression_statement assignment identifier true break_statement if_statement identifier block expression_statement yield expression_list identifier call attribute 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 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_end identifier argument_list attribute identifier identifier else_clause block expression_statement yield expression_list identifier string string_start string_content string_end
Description strings in the name table must not exceed 200 characters.
def case_insensitive_file_search(directory, pattern): try: return os.path.join( directory, [filename for filename in os.listdir(directory) if re.search(pattern, filename, re.IGNORECASE)][0]) except IndexError: print("{0} not found".format(pattern)) raise
module function_definition identifier parameters identifier identifier block try_statement block return_statement call attribute attribute identifier identifier identifier argument_list identifier subscript list_comprehension identifier for_in_clause identifier call attribute identifier identifier argument_list identifier if_clause call attribute identifier identifier argument_list identifier identifier attribute identifier identifier integer except_clause identifier block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier raise_statement
Looks for file with pattern with case insensitive search
def str_deps(self): lines = [] app = lines.append app("Dependencies of node %s:" % str(self)) for i, dep in enumerate(self.deps): app("%d) %s, status=%s" % (i, dep.info, str(dep.status))) return "\n".join(lines)
module function_definition identifier parameters identifier block expression_statement assignment identifier list expression_statement assignment identifier attribute identifier identifier expression_statement call identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list identifier for_statement pattern_list identifier identifier call identifier argument_list attribute identifier identifier block expression_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier attribute identifier identifier call identifier argument_list attribute identifier identifier return_statement call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier
Return the string representation of the dependencies of the node.
def os_requires_version(ostack_release, pkg): def wrap(f): @wraps(f) def wrapped_f(*args): if os_release(pkg) < ostack_release: raise Exception("This hook is not supported on releases" " before %s" % ostack_release) f(*args) return wrapped_f return wrap
module function_definition identifier parameters identifier identifier block function_definition identifier parameters identifier block decorated_definition decorator call identifier argument_list identifier function_definition identifier parameters list_splat_pattern identifier block if_statement comparison_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end identifier expression_statement call identifier argument_list list_splat identifier return_statement identifier return_statement identifier
Decorator for hook to specify minimum supported release
def remove_mixins(target): mixedins_by_name = Mixin.get_mixedins_by_name(target).copy() for _name in mixedins_by_name: while True: try: Mixin.remove_mixin(target, _name) except Mixin.MixInError: break
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier identifier argument_list for_statement identifier identifier block while_statement true block try_statement block expression_statement call attribute identifier identifier argument_list identifier identifier except_clause attribute identifier identifier block break_statement
Tries to get back target in a no mixin consistent state.
def from_notebook_node(self, nb, resources=None, **kw): from weasyprint import HTML, CSS nb = copy.deepcopy(nb) output, resources = super(OneCodexPDFExporter, self).from_notebook_node( nb, resources=resources, **kw ) buf = BytesIO() HTML(string=output).write_pdf( buf, stylesheets=[CSS(os.path.join(ASSETS_PATH, CSS_TEMPLATE_FILE))] ) buf.seek(0) return buf.read(), resources
module function_definition identifier parameters identifier identifier default_parameter identifier none dictionary_splat_pattern identifier block import_from_statement dotted_name identifier dotted_name identifier dotted_name identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment pattern_list identifier identifier call attribute call identifier argument_list identifier identifier identifier argument_list identifier keyword_argument identifier identifier dictionary_splat identifier expression_statement assignment identifier call identifier argument_list expression_statement call attribute call identifier argument_list keyword_argument identifier identifier identifier argument_list identifier keyword_argument identifier list call identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list integer return_statement expression_list call attribute identifier identifier argument_list identifier
Takes output of OneCodexHTMLExporter and runs Weasyprint to get a PDF.
def _get_implicit_requirements( self, fields, requirements ): for name, field in six.iteritems(fields): source = field.source requires = getattr(field, 'requires', None) or [source] for require in requires: if not require: continue requirement = require.split('.') if requirement[-1] == '': requirement[-1] = '*' requirements.insert(requirement, TreeMap(), update=True)
module function_definition identifier parameters identifier identifier identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier boolean_operator call identifier argument_list identifier string string_start string_content string_end none list identifier for_statement identifier identifier block if_statement not_operator identifier block continue_statement expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator subscript identifier unary_operator integer string string_start string_end block expression_statement assignment subscript identifier unary_operator integer string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier call identifier argument_list keyword_argument identifier true
Extract internal prefetch requirements from serializer fields.
def compile_(self): from Cython import Build argv = copy.deepcopy(sys.argv) sys.argv = [sys.argv[0], 'build_ext', '--build-lib='+self.buildpath] exc_modules = [ distutils.extension.Extension( 'hydpy.cythons.autogen.'+self.cyname, [self.pyxfilepath], extra_compile_args=['-O2'])] distutils.core.setup(ext_modules=Build.cythonize(exc_modules), include_dirs=[numpy.get_include()]) sys.argv = argv
module function_definition identifier parameters identifier block import_from_statement dotted_name identifier dotted_name identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier list subscript attribute identifier identifier integer string string_start string_content string_end binary_operator string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier list call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier list attribute identifier identifier keyword_argument identifier list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list identifier keyword_argument identifier list call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier identifier
Translate cython code to C code and compile it.
def _create_stacking_set(estimators, estimators_features, estimators_weight, X, combination): n_samples = X.shape[0] valid_estimators = np.nonzero(estimators_weight)[0] n_valid_estimators = valid_estimators.shape[0] X_stacking = np.zeros((n_samples, n_valid_estimators)) for e in range(n_valid_estimators): if combination in ['stacking', 'stacking_bmr']: X_stacking[:, e] = estimators[valid_estimators[e]].predict(X[:, estimators_features[valid_estimators[e]]]) elif combination in ['stacking_proba', 'stacking_proba_bmr']: X_stacking[:, e] = estimators[valid_estimators[e]].predict_proba(X[:, estimators_features[valid_estimators[e]]])[:, 1] return X_stacking
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier integer expression_statement assignment identifier subscript call attribute identifier identifier argument_list identifier integer expression_statement assignment identifier subscript attribute identifier identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list tuple identifier identifier for_statement identifier call identifier argument_list identifier block if_statement comparison_operator identifier list string string_start string_content string_end string string_start string_content string_end block expression_statement assignment subscript identifier slice identifier call attribute subscript identifier subscript identifier identifier identifier argument_list subscript identifier slice subscript identifier subscript identifier identifier elif_clause comparison_operator identifier list string string_start string_content string_end string string_start string_content string_end block expression_statement assignment subscript identifier slice identifier subscript call attribute subscript identifier subscript identifier identifier identifier argument_list subscript identifier slice subscript identifier subscript identifier identifier slice integer return_statement identifier
Private function used to create the stacking training set.
def _clone_args(self): keys = list(self.keys) kw = {} if self.allow_any or self.extras: kw['allow_extra'] = list(self.extras) if self.allow_any: kw['allow_extra'].append('*') kw['allow_extra_trafaret'] = self.extras_trafaret if self.ignore_any or self.ignore: kw['ignore_extra'] = list(self.ignore) if self.ignore_any: kw['ignore_any'].append('*') return keys, kw
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier dictionary if_statement boolean_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list attribute identifier identifier if_statement attribute identifier identifier block expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier if_statement boolean_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list attribute identifier identifier if_statement attribute identifier identifier block expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end return_statement expression_list identifier identifier
return args to create new Dict clone
def find_optconf(self, pconfs): self.set_pconfs(pconfs) optconf = self.manager.select_qadapter(pconfs) return optconf
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier return_statement identifier
Find the optimal Parallel configuration.
def search(self, start_ts, end_ts): query = '_ts: [%s TO %s]' % (start_ts, end_ts) return self._stream_search(query)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple identifier identifier return_statement call attribute identifier identifier argument_list identifier
Called to query Solr for documents in a time range.
def complete_url(self, url): if self.base_url: return urlparse.urljoin(self.base_url, url) else: return url
module function_definition identifier parameters identifier identifier block if_statement attribute identifier identifier block return_statement call attribute identifier identifier argument_list attribute identifier identifier identifier else_clause block return_statement identifier
Completes a given URL with this instance's URL base.
def objify(self, doc, columns=None): cols = columns or doc[METADATA][COLUMNS] data = {} for col in cols: if col not in doc[METADATA][LENGTHS]: d = [np.nan] else: d = decompress(doc[DATA][doc[METADATA][LENGTHS][col][0]: doc[METADATA][LENGTHS][col][1] + 1]) d = np.frombuffer(d, doc[METADATA][DTYPE][col]) if MASK in doc[METADATA] and col in doc[METADATA][MASK]: mask_data = decompress(doc[METADATA][MASK][col]) mask = np.frombuffer(mask_data, 'bool') d = ma.masked_array(d, mask) data[col] = d return pd.DataFrame(data, columns=cols, copy=True)[cols]
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment identifier boolean_operator identifier subscript subscript identifier identifier identifier expression_statement assignment identifier dictionary for_statement identifier identifier block if_statement comparison_operator identifier subscript subscript identifier identifier identifier block expression_statement assignment identifier list attribute identifier identifier else_clause block expression_statement assignment identifier call identifier argument_list subscript subscript identifier identifier slice subscript subscript subscript subscript identifier identifier identifier identifier integer binary_operator subscript subscript subscript subscript identifier identifier identifier identifier integer integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier subscript subscript subscript identifier identifier identifier identifier if_statement boolean_operator comparison_operator identifier subscript identifier identifier comparison_operator identifier subscript subscript identifier identifier identifier block expression_statement assignment identifier call identifier argument_list subscript subscript subscript identifier identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment subscript identifier identifier identifier return_statement subscript call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier true identifier
Decode a Pymongo SON object into an Pandas DataFrame
def UpdateKnowledgeBase(self, response, provides): if isinstance(response, rdf_anomaly.Anomaly): return if isinstance(response, rdf_client.User): self.knowledge_base.MergeOrAddUser(response) return if isinstance(response, rdf_protodict.Dict): response_dict = response.ToDict() for attribute, value in iteritems(response_dict): if attribute in provides: self.SetKnowledgeBaseValue(attribute, value) return if len(provides) == 1: self.SetKnowledgeBaseValue(provides[0], response)
module function_definition identifier parameters identifier identifier identifier block if_statement call identifier argument_list identifier attribute identifier identifier block return_statement if_statement call identifier argument_list identifier attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement if_statement call identifier argument_list identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list for_statement pattern_list identifier identifier call identifier argument_list identifier block if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier return_statement if_statement comparison_operator call identifier argument_list identifier integer block expression_statement call attribute identifier identifier argument_list subscript identifier integer identifier
Set values in the knowledge base based on responses.
def __RegisterDescriptor(self, new_descriptor): if not isinstance(new_descriptor, ( extended_descriptor.ExtendedMessageDescriptor, extended_descriptor.ExtendedEnumDescriptor)): raise ValueError('Cannot add descriptor of type %s' % ( type(new_descriptor),)) full_name = self.__ComputeFullName(new_descriptor.name) if full_name in self.__message_registry: raise ValueError( 'Attempt to re-register descriptor %s' % full_name) if full_name not in self.__nascent_types: raise ValueError('Directly adding types is not supported') new_descriptor.full_name = full_name self.__message_registry[full_name] = new_descriptor if isinstance(new_descriptor, extended_descriptor.ExtendedMessageDescriptor): self.__current_env.message_types.append(new_descriptor) elif isinstance(new_descriptor, extended_descriptor.ExtendedEnumDescriptor): self.__current_env.enum_types.append(new_descriptor) self.__unknown_types.discard(full_name) self.__nascent_types.remove(full_name)
module function_definition identifier parameters identifier identifier block if_statement not_operator call identifier argument_list identifier tuple attribute identifier identifier attribute identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier if_statement comparison_operator identifier attribute identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier if_statement comparison_operator identifier attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier identifier expression_statement assignment subscript attribute identifier identifier identifier identifier if_statement call identifier argument_list identifier attribute identifier identifier block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier elif_clause call identifier argument_list identifier attribute identifier identifier block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Register the given descriptor in this registry.
def dropping(n): if n < 0: raise ValueError("Cannot drop fewer than zero ({}) items".format(n)) def dropping_transducer(reducer): return Dropping(reducer, n) return dropping_transducer
module function_definition identifier parameters identifier block if_statement comparison_operator identifier integer block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier function_definition identifier parameters identifier block return_statement call identifier argument_list identifier identifier return_statement identifier
Create a transducer which drops the first n items
def _uriPrefix(element): i = element.tag.find('}') if i < 0: return "" return element.tag[:i+1]
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier integer block return_statement string string_start string_end return_statement subscript attribute identifier identifier slice binary_operator identifier integer
Return xmlns prefix of the given element.
def connect(self): if self._sock: return try: sock = self._connect() except socket.error: e = sys.exc_info()[1] raise ConnectionError(self._error_message(e)) self._sock = sock try: self.on_connect() except SSDBError: self.disconnect() raise for callback in self._connect_callbacks: callback(self)
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block return_statement try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list except_clause attribute identifier identifier block expression_statement assignment identifier subscript call attribute identifier identifier argument_list integer raise_statement call identifier argument_list call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier identifier try_statement block expression_statement call attribute identifier identifier argument_list except_clause identifier block expression_statement call attribute identifier identifier argument_list raise_statement for_statement identifier attribute identifier identifier block expression_statement call identifier argument_list identifier
Connects to the SSDB server if not already connected
def revert_metadata(files): for file_path in files: tags = EasyMP3(file_path) tags.delete() tags.save()
module function_definition identifier parameters identifier block for_statement identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list
Removes all tags from a mp3 file
def exclude_chars(text, exclusion=None): exclusion = [] if exclusion is None else exclusion regexp = r"|".join([select_regexp_char(x) for x in exclusion]) or r'' return re.sub(regexp, '', text)
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier conditional_expression list comparison_operator identifier none identifier expression_statement assignment identifier boolean_operator call attribute string string_start string_content string_end identifier argument_list list_comprehension call identifier argument_list identifier for_in_clause identifier identifier string string_start string_end return_statement call attribute identifier identifier argument_list identifier string string_start string_end identifier
Clean text string of simbols in exclusion list.
def read(self): if not self.fname: return try: with open(self.fname, "r") as f: wpid = int(f.read() or 0) if wpid <= 0: return return wpid except IOError: return
module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block return_statement try_statement 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 boolean_operator call attribute identifier identifier argument_list integer if_statement comparison_operator identifier integer block return_statement return_statement identifier except_clause identifier block return_statement
Validate pidfile and make it stale if needed
def normcdf(x, log=False): y = np.atleast_1d(x).copy() flib.normcdf(y) if log: if (y>0).all(): return np.log(y) return -np.inf return y
module function_definition identifier parameters identifier default_parameter identifier false block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier if_statement identifier block if_statement call attribute parenthesized_expression comparison_operator identifier integer identifier argument_list block return_statement call attribute identifier identifier argument_list identifier return_statement unary_operator attribute identifier identifier return_statement identifier
Normal cumulative density function.
def init_quotas(sender, instance, created=False, **kwargs): if not created: return for field in sender.get_quotas_fields(): try: field.get_or_create_quota(scope=instance) except CreationConditionFailedQuotaError: pass
module function_definition identifier parameters identifier identifier default_parameter identifier false dictionary_splat_pattern identifier block if_statement not_operator identifier block return_statement for_statement identifier call attribute identifier identifier argument_list block try_statement block expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier except_clause identifier block pass_statement
Initialize new instances quotas
def airwires(board, showgui=0): 'search for airwires in eagle board' board = Path(board).expand().abspath() file_out = tempfile.NamedTemporaryFile(suffix='.txt', delete=0) file_out.close() ulp = ulp_templ.replace('FILE_NAME', file_out.name) file_ulp = tempfile.NamedTemporaryFile(suffix='.ulp', delete=0) file_ulp.write(ulp.encode('utf-8')) file_ulp.close() commands = [ 'run ' + file_ulp.name, 'quit', ] command_eagle(board, commands=commands, showgui=showgui) n = int(Path(file_out.name).text()) Path(file_out.name).remove() Path(file_ulp.name).remove() return n
module function_definition identifier parameters identifier default_parameter identifier integer block expression_statement string string_start string_content string_end expression_statement assignment identifier call attribute call attribute call identifier argument_list identifier identifier argument_list identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier integer expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier integer expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier list binary_operator string string_start string_content string_end attribute identifier identifier string string_start string_content string_end expression_statement call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier expression_statement assignment identifier call identifier argument_list call attribute call identifier argument_list attribute identifier identifier identifier argument_list expression_statement call attribute call identifier argument_list attribute identifier identifier identifier argument_list expression_statement call attribute call identifier argument_list attribute identifier identifier identifier argument_list return_statement identifier
search for airwires in eagle board
async def _storeAppt(self, appt): await self._hivedict.set(appt.iden, appt.pack())
module function_definition identifier parameters identifier identifier block expression_statement await call attribute attribute identifier identifier identifier argument_list attribute identifier identifier call attribute identifier identifier argument_list
Store a single appointment
def export_account_state(self, account_state): return { 'address': account_state['address'], 'type': account_state['type'], 'credit_value': '{}'.format(account_state['credit_value']), 'debit_value': '{}'.format(account_state['debit_value']), 'lock_transfer_block_id': account_state['lock_transfer_block_id'], 'block_id': account_state['block_id'], 'vtxindex': account_state['vtxindex'], 'txid': account_state['txid'], }
module function_definition identifier parameters identifier identifier block return_statement dictionary pair string string_start string_content string_end subscript identifier string string_start string_content string_end pair string string_start string_content string_end subscript identifier string string_start string_content string_end pair string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list subscript identifier string string_start string_content string_end pair string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list subscript identifier string string_start string_content string_end pair string string_start string_content string_end subscript identifier string string_start string_content string_end pair string string_start string_content string_end subscript identifier string string_start string_content string_end pair string string_start string_content string_end subscript identifier string string_start string_content string_end pair string string_start string_content string_end subscript identifier string string_start string_content string_end
Make an account state presentable to external consumers
def path_yield(path): for part in (x for x in path.strip(SEP).split(SEP) if x not in (None, '')): yield part
module function_definition identifier parameters identifier block for_statement identifier generator_expression identifier for_in_clause identifier call attribute call attribute identifier identifier argument_list identifier identifier argument_list identifier if_clause comparison_operator identifier tuple none string string_start string_end block expression_statement yield identifier
Yield on all path parts.
def cmd_rc(self, args): if len(args) != 2: print("Usage: rc <channel|all> <pwmvalue>") return value = int(args[1]) if value > 65535 or value < -1: raise ValueError("PWM value must be a positive integer between 0 and 65535") if value == -1: value = 65535 channels = self.override if args[0] == 'all': for i in range(16): channels[i] = value else: channel = int(args[0]) if channel < 1 or channel > 16: print("Channel must be between 1 and 8 or 'all'") return channels[channel - 1] = value self.set_override(channels)
module function_definition identifier parameters identifier identifier block if_statement comparison_operator call identifier argument_list identifier integer block expression_statement call identifier argument_list string string_start string_content string_end return_statement expression_statement assignment identifier call identifier argument_list subscript identifier integer if_statement boolean_operator comparison_operator identifier integer comparison_operator identifier unary_operator integer block raise_statement call identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier unary_operator integer block expression_statement assignment identifier integer expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator subscript identifier integer string string_start string_content string_end block for_statement identifier call identifier argument_list integer block expression_statement assignment subscript identifier identifier identifier else_clause block expression_statement assignment identifier call identifier argument_list subscript identifier integer if_statement boolean_operator comparison_operator identifier integer comparison_operator identifier integer block expression_statement call identifier argument_list string string_start string_content string_end return_statement expression_statement assignment subscript identifier binary_operator identifier integer identifier expression_statement call attribute identifier identifier argument_list identifier
handle RC value override
def AnalizarRemito(self, ret, archivo=None): "Extrae el resultado del remito, si existen en la respuesta XML" if ret: self.CodRemito = ret.get("codRemito") self.TipoComprobante = ret.get("tipoComprobante") self.PuntoEmision = ret.get("puntoEmision") datos_aut = ret.get('datosAutorizacion') if datos_aut: self.NroRemito = datos_aut.get('nroRemito') self.CodAutorizacion = datos_aut.get('codAutorizacion') self.FechaEmision = datos_aut.get('fechaEmision') self.FechaVencimiento = datos_aut.get('fechaVencimiento') self.Estado = ret.get('estado') self.Resultado = ret.get('resultado') self.QR = ret.get('qr') or "" if archivo: qr = base64.b64decode(self.QR) f = open(archivo, "wb") f.write(qr) f.close()
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement string string_start string_content string_end if_statement identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier boolean_operator call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list
Extrae el resultado del remito, si existen en la respuesta XML
def _generate_class_comment(self, data_type): if is_struct_type(data_type): class_type = 'struct' elif is_union_type(data_type): class_type = 'union' else: raise TypeError('Can\'t handle type %r' % type(data_type)) self.emit(comment_prefix) self.emit_wrapped_text( 'The `{}` {}.'.format(fmt_class(data_type.name), class_type), prefix=comment_prefix) if data_type.doc: self.emit(comment_prefix) self.emit_wrapped_text( self.process_doc(data_type.doc, self._docf), prefix=comment_prefix) self.emit(comment_prefix) protocol_str = ( 'This class implements the `DBSerializable` protocol ' '(serialize and deserialize instance methods), which is required ' 'for all Obj-C SDK API route objects.') self.emit_wrapped_text( protocol_str.format(fmt_class_prefix(data_type), class_type), prefix=comment_prefix) self.emit(comment_prefix)
module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier block expression_statement assignment identifier string string_start string_content string_end elif_clause call identifier argument_list identifier block expression_statement assignment identifier string string_start string_content string_end else_clause block raise_statement call identifier argument_list binary_operator string string_start string_content escape_sequence string_end call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list call identifier argument_list attribute identifier identifier identifier keyword_argument identifier identifier if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment 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 expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list call identifier argument_list identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list identifier
Emits a generic class comment for a union or struct.
def extract(domain): translations_dir = _get_translations_dir() domain = _get_translations_domain(domain) babel_cfg = _get_babel_cfg() pot = os.path.join(translations_dir, f'{domain}.pot') return _run(f'extract -F {babel_cfg} -o {pot} .')
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier string string_start interpolation identifier string_content string_end return_statement call identifier argument_list string string_start string_content interpolation identifier string_content interpolation identifier string_content string_end
Extract newly added translations keys from source code.
def comments_nb_counts(): recid = request.view_args.get('recid') if recid is None: return elif recid == 0: return 0 else: return CmtRECORDCOMMENT.count(*[ CmtRECORDCOMMENT.id_bibrec == recid, CmtRECORDCOMMENT.star_score == 0, CmtRECORDCOMMENT.status.notin_(['dm', 'da']) ])
module function_definition identifier parameters block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier none block return_statement elif_clause comparison_operator identifier integer block return_statement integer else_clause block return_statement call attribute identifier identifier argument_list list_splat list comparison_operator attribute identifier identifier identifier comparison_operator attribute identifier identifier integer call attribute attribute identifier identifier identifier argument_list list string string_start string_content string_end string string_start string_content string_end
Get number of comments for the record `recid`.
def _compass_position(self, player_x, player_y): map_dim = self._map.size_x third = map_dim * (1/3.0) for direction in mgz.const.COMPASS: point = mgz.const.COMPASS[direction] xlower = point[0] * map_dim xupper = (point[0] * map_dim) + third ylower = point[1] * map_dim yupper = (point[1] * map_dim) + third if (player_x >= xlower and player_x < xupper and player_y >= ylower and player_y < yupper): return direction
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier binary_operator identifier parenthesized_expression binary_operator integer float for_statement identifier attribute attribute identifier identifier identifier block expression_statement assignment identifier subscript attribute attribute identifier identifier identifier identifier expression_statement assignment identifier binary_operator subscript identifier integer identifier expression_statement assignment identifier binary_operator parenthesized_expression binary_operator subscript identifier integer identifier identifier expression_statement assignment identifier binary_operator subscript identifier integer identifier expression_statement assignment identifier binary_operator parenthesized_expression binary_operator subscript identifier integer identifier identifier if_statement parenthesized_expression boolean_operator boolean_operator boolean_operator comparison_operator identifier identifier comparison_operator identifier identifier comparison_operator identifier identifier comparison_operator identifier identifier block return_statement identifier
Get compass position of player.
def track_to_ref(track, with_track_no=False): if with_track_no and track.track_no > 0: name = '%d - ' % track.track_no else: name = '' for artist in track.artists: if len(name) > 0: name += ', ' name += artist.name if (len(name)) > 0: name += ' - ' name += track.name return Ref.track(uri=track.uri, name=name)
module function_definition identifier parameters identifier default_parameter identifier false block if_statement boolean_operator identifier comparison_operator attribute identifier identifier integer block expression_statement assignment identifier binary_operator string string_start string_content string_end attribute identifier identifier else_clause block expression_statement assignment identifier string string_start string_end for_statement identifier attribute identifier identifier block if_statement comparison_operator call identifier argument_list identifier integer block expression_statement augmented_assignment identifier string string_start string_content string_end expression_statement augmented_assignment identifier attribute identifier identifier if_statement comparison_operator parenthesized_expression call identifier argument_list identifier integer block expression_statement augmented_assignment identifier string string_start string_content string_end expression_statement augmented_assignment identifier attribute identifier identifier return_statement call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier
Convert a mopidy track to a mopidy ref.
def start_aeidon(): extensions = ['ass', 'srt', 'ssa', 'sub'] Config.filenames = prep_files(Config.args, extensions) Config.patterns = pattern_logic_aeidon() for filename in Config.filenames: AeidonProject(filename)
module function_definition identifier parameters block 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 expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list for_statement identifier attribute identifier identifier block expression_statement call identifier argument_list identifier
Prepare filenames and patterns then process subtitles with aeidon.
def cli(): objcli = WrHierCli(sys.argv[1:]) fouts_txt = objcli.get_fouts() if fouts_txt: for fout_txt in fouts_txt: objcli.wrtxt_hier(fout_txt) else: objcli.prt_hier(sys.stdout)
module function_definition identifier parameters block expression_statement assignment identifier call identifier argument_list subscript attribute identifier identifier slice integer expression_statement assignment identifier call attribute identifier identifier argument_list if_statement identifier block for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list attribute identifier identifier
Command-line script to print a GO term's lower-level hierarchy.
def _get_error_message(self, response): error_message = 'An error occurred processing your request.' try: content = response.json() error_message = content['errors'][0]['message'] except TypeError: error_message = content['errors'] except ValueError: pass except (KeyError, IndexError): pass return error_message
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier string string_start string_content string_end try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier subscript subscript subscript identifier string string_start string_content string_end integer string string_start string_content string_end except_clause identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end except_clause identifier block pass_statement except_clause tuple identifier identifier block pass_statement return_statement identifier
Parse and return the first error message
def _store(self, con): self._con = con self._transaction = False self._closed = False self._usage = 0
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier false expression_statement assignment attribute identifier identifier false expression_statement assignment attribute identifier identifier integer
Store a database connection for subsequent use.
def _set_camera_properties(self, msg): focal_x = msg.K[0] focal_y = msg.K[4] center_x = msg.K[2] center_y = msg.K[5] im_height = msg.height im_width = msg.width self._camera_intr = CameraIntrinsics(self._frame, focal_x, focal_y, center_x, center_y, height=im_height, width=im_width)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier integer expression_statement assignment identifier subscript attribute identifier identifier integer expression_statement assignment identifier subscript attribute identifier identifier integer expression_statement assignment identifier subscript attribute identifier identifier integer expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier identifier identifier identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
Set the camera intrinsics from an info msg.
def removeItem(self, item): try: self.tree.removeItem(item) except AttributeError, e: raise VersionError('Saved versions are immutable')
module function_definition identifier parameters identifier identifier block try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list identifier except_clause identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end
Removes an item if the tree is mutable
def assert_wildtype_matches(self, mutation): readwt = self.getAminoAcid(self.getAtomLine(mutation.Chain, mutation.ResidueID)) assert(mutation.WildTypeAA == residue_type_3to1_map[readwt])
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier assert_statement parenthesized_expression comparison_operator attribute identifier identifier subscript identifier identifier
Check that the wildtype of the Mutation object matches the PDB sequence.
def cd(self, remote): try: self.conn.cwd(remote) except Exception: return False else: return self.pwd()
module function_definition identifier parameters identifier identifier block try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list identifier except_clause identifier block return_statement false else_clause block return_statement call attribute identifier identifier argument_list
Change working directory on server
def handle_pubrec(self): self.logger.info("PUBREC received") ret, mid = self.in_packet.read_uint16() if ret != NC.ERR_SUCCESS: return ret evt = event.EventPubrec(mid) self.push_event(evt) return NC.ERR_SUCCESS
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list if_statement comparison_operator identifier attribute identifier identifier block return_statement identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier return_statement attribute identifier identifier
Handle incoming PUBREC packet.
def compile_kernel(self, instance, verbose): logging.debug('compile_kernel ' + instance.name) func = None try: func = self.dev.compile(instance.name, instance.kernel_string) except Exception as e: if "uses too much shared data" in str(e): logging.debug('compile_kernel failed due to kernel using too much shared memory') if verbose: print("skipping config", instance.name, "reason: too much shared memory used") else: logging.debug('compile_kernel failed due to error: ' + str(e)) print("Error while compiling:", instance.name) raise e return func
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier none try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier attribute identifier identifier except_clause as_pattern identifier as_pattern_target identifier block if_statement comparison_operator string string_start string_content string_end call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end if_statement identifier block expression_statement call identifier argument_list string string_start string_content string_end attribute identifier identifier string string_start string_content string_end else_clause block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list identifier expression_statement call identifier argument_list string string_start string_content string_end attribute identifier identifier raise_statement identifier return_statement identifier
compile the kernel for this specific instance
def aggregate(self): from nefertari.elasticsearch import ES aggregations_params = self.pop_aggregations_params() if self.view._auth_enabled: self.check_aggregations_privacy(aggregations_params) self.stub_wrappers() return ES(self.view.Model.__name__).aggregate( _aggregations_params=aggregations_params, **self._query_params)
module function_definition identifier parameters identifier block import_from_statement dotted_name identifier identifier dotted_name identifier expression_statement assignment identifier call attribute identifier identifier argument_list if_statement attribute attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list return_statement call attribute call identifier argument_list attribute attribute attribute identifier identifier identifier identifier identifier argument_list keyword_argument identifier identifier dictionary_splat attribute identifier identifier
Perform aggregation and return response.
def resetTimeout(self): if self.__timeoutCall is not None and self.timeOut is not None: self.__timeoutCall.reset(self.timeOut)
module function_definition identifier parameters identifier block if_statement boolean_operator comparison_operator attribute identifier identifier none comparison_operator attribute identifier identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier
Reset the timeout count down
def action_cancel(self): self.write({'state': 'cancelled'}) for rec in self: rec.message_post( subtype='mt_comment', body=_( 'Change request <b>%s</b> has been cancelled by %s.' ) % (rec.display_name, self.env.user.name) )
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end string string_start string_content string_end for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier binary_operator call identifier argument_list string string_start string_content string_end tuple attribute identifier identifier attribute attribute attribute identifier identifier identifier identifier
Set a change request as cancelled.
def do_printPolicy(self,args): parser = CommandArgumentParser("printPolicy") args = vars(parser.parse_args(args)) policy = self.client.describe_policies(AutoScalingGroupName=self.scalingGroup) pprint(policy)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier expression_statement call identifier argument_list identifier
Print the autoscaling policy
def _set_operable_view(self, session): for obj_name in self._operable_views: if self._operable_views[obj_name] == ACTIVE: try: getattr(session, 'use_active_' + obj_name + '_view')() except AttributeError: pass else: try: getattr(session, 'use_any_status_' + obj_name + '_view')() except AttributeError: pass
module function_definition identifier parameters identifier identifier block for_statement identifier attribute identifier identifier block if_statement comparison_operator subscript attribute identifier identifier identifier identifier block try_statement block expression_statement call call identifier argument_list identifier binary_operator binary_operator string string_start string_content string_end identifier string string_start string_content string_end argument_list except_clause identifier block pass_statement else_clause block try_statement block expression_statement call call identifier argument_list identifier binary_operator binary_operator string string_start string_content string_end identifier string string_start string_content string_end argument_list except_clause identifier block pass_statement
Sets the underlying operable views to match current view
def show_list(self, the_list, cur_p=''): current_page_num = int(cur_p) if cur_p else 1 current_page_num = 1 if current_page_num < 1 else current_page_num num_of_cat = MCollect.count_of_user(self.userinfo.uid) page_num = int(num_of_cat / CMS_CFG['list_num']) + 1 kwd = {'current_page': current_page_num} self.render('misc/collect/list.html', recs_collect=MCollect.query_pager_by_all(self.userinfo.uid, current_page_num).objects(), pager=tools.gen_pager_purecss('/collect/{0}'.format(the_list), page_num, current_page_num), userinfo=self.userinfo, cfg=CMS_CFG, kwd=kwd)
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_end block expression_statement assignment identifier conditional_expression call identifier argument_list identifier identifier integer expression_statement assignment identifier conditional_expression integer comparison_operator identifier integer identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute attribute identifier identifier identifier expression_statement assignment identifier binary_operator call identifier argument_list binary_operator identifier subscript identifier string string_start string_content string_end integer expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier call attribute call attribute identifier identifier argument_list attribute attribute identifier identifier identifier identifier identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
List of the user collections.
def visit_FunctionDef(self, node): node = self.get_function_node(node) if node is not None: node._async = False
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement assignment attribute identifier identifier false
Visit a function node.
def add_parser_from_field(self, name, field_cls): self.__parser_map__[name] = _field2method(field_cls, method_name=name)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier call identifier argument_list identifier keyword_argument identifier identifier
Register a new parser method with name ``name``, given a marshmallow ``Field``.
def print_controllers(): _check_import() pp = pprint.PrettyPrinter(indent=2) for discovery in find_all_controllers(): pp.pprint(discovery.controller)
module function_definition identifier parameters block expression_statement call identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier integer for_statement identifier call identifier argument_list block expression_statement call attribute identifier identifier argument_list attribute identifier identifier
Pretty-print all controllers found
def get(self, name, defval=None): for frame in reversed(self.frames): valu = frame.get(name, s_common.novalu) if valu != s_common.novalu: return valu task = self.ctors.get(name) if task is not None: func, args, kwargs = task item = func(*args, **kwargs) self.frames[-1][name] = item return item return defval
module function_definition identifier parameters identifier identifier default_parameter identifier none block for_statement identifier call identifier argument_list attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier attribute identifier identifier if_statement comparison_operator identifier attribute identifier identifier block return_statement identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement assignment pattern_list identifier identifier identifier identifier expression_statement assignment identifier call identifier argument_list list_splat identifier dictionary_splat identifier expression_statement assignment subscript subscript attribute identifier identifier unary_operator integer identifier identifier return_statement identifier return_statement identifier
Retrieve a value from the closest scope frame.
def avroize_type(field_type, name_prefix=""): if isinstance(field_type, MutableSequence): for field in field_type: avroize_type(field, name_prefix) elif isinstance(field_type, MutableMapping): if field_type["type"] in ("enum", "record"): if "name" not in field_type: field_type["name"] = name_prefix + Text(uuid.uuid4()) if field_type["type"] == "record": avroize_type(field_type["fields"], name_prefix) if field_type["type"] == "array": avroize_type(field_type["items"], name_prefix) if isinstance(field_type["type"], MutableSequence): for ctype in field_type["type"]: avroize_type(ctype, name_prefix) return field_type
module function_definition identifier parameters identifier default_parameter identifier string string_start string_end block if_statement call identifier argument_list identifier identifier block for_statement identifier identifier block expression_statement call identifier argument_list identifier identifier elif_clause call identifier argument_list identifier identifier block if_statement comparison_operator subscript identifier string string_start string_content string_end tuple string string_start string_content string_end string string_start string_content string_end block if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end binary_operator identifier call identifier argument_list call attribute identifier identifier argument_list if_statement comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end block expression_statement call identifier argument_list subscript identifier string string_start string_content string_end identifier if_statement comparison_operator subscript identifier string string_start string_content string_end string string_start string_content string_end block expression_statement call identifier argument_list subscript identifier string string_start string_content string_end identifier if_statement call identifier argument_list subscript identifier string string_start string_content string_end identifier block for_statement identifier subscript identifier string string_start string_content string_end block expression_statement call identifier argument_list identifier identifier return_statement identifier
adds missing information to a type so that CWL types are valid in schema_salad.
def sortedSemver(versions, sort="asc"): if versions and isinstance(versions, (list, tuple)): if PY2: return sorted(versions, cmp=semver.compare, reverse=True if sort.upper() == "DESC" else False) else: from functools import cmp_to_key return sorted(versions, key=cmp_to_key(semver.compare), reverse=True if sort.upper() == "DESC" else False) else: raise TypeError("Invaild Versions, a list or tuple is right.")
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end block if_statement boolean_operator identifier call identifier argument_list identifier tuple identifier identifier block if_statement identifier block return_statement call identifier argument_list identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier conditional_expression true comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end false else_clause block import_from_statement dotted_name identifier dotted_name identifier return_statement call identifier argument_list identifier keyword_argument identifier call identifier argument_list attribute identifier identifier keyword_argument identifier conditional_expression true comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end false else_clause block raise_statement call identifier argument_list string string_start string_content string_end
Semantically sort the list of version Numbers
def _plot(self): for serie in self.series[::-1 if self.stack_from_top else 1]: self.line(serie) for serie in self.secondary_series[::-1 if self.stack_from_top else 1]: self.line(serie, True)
module function_definition identifier parameters identifier block for_statement identifier subscript attribute identifier identifier slice conditional_expression unary_operator integer attribute identifier identifier integer block expression_statement call attribute identifier identifier argument_list identifier for_statement identifier subscript attribute identifier identifier slice conditional_expression unary_operator integer attribute identifier identifier integer block expression_statement call attribute identifier identifier argument_list identifier true
Plot stacked serie lines and stacked secondary lines
def text(self): if self.driver.w3c: return self.driver.execute(Command.W3C_GET_ALERT_TEXT)["value"] else: return self.driver.execute(Command.GET_ALERT_TEXT)["value"]
module function_definition identifier parameters identifier block if_statement attribute attribute identifier identifier identifier block return_statement subscript call attribute attribute identifier identifier identifier argument_list attribute identifier identifier string string_start string_content string_end else_clause block return_statement subscript call attribute attribute identifier identifier identifier argument_list attribute identifier identifier string string_start string_content string_end
Gets the text of the Alert.
def register_routes(self): routes = self.flatten_urls(self.urls) self.controllers = {} controller_names = set() for route in routes: cname = route['endpoint'].split('.')[0] controller_names.add(cname) for cname in controller_names: attr = getattr(self.mcontrollers, cname) instance = attr(request, response) self.controllers[cname] = instance for route in routes: cname, aname = route['endpoint'].split('.') action = getattr(self.controllers[cname], aname) self.wsgi.route(route['url'], route['methods'], action)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier dictionary expression_statement assignment identifier call identifier argument_list for_statement identifier identifier block expression_statement assignment identifier subscript call attribute subscript identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end integer expression_statement call attribute identifier identifier argument_list identifier for_statement identifier identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment subscript attribute identifier identifier identifier identifier for_statement identifier identifier block expression_statement assignment pattern_list identifier identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list subscript attribute identifier identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end identifier
Function creates instances of controllers, adds into bottle routes
def zoomset_cb(self, setting, value, channel): if not self.gui_up: return info = channel.extdata._info_info if info is None: return scale_x, scale_y = value if scale_x == scale_y: text = self.fv.scale2text(scale_x) else: textx = self.fv.scale2text(scale_x) texty = self.fv.scale2text(scale_y) text = "X: %s Y: %s" % (textx, texty) info.winfo.zoom.set_text(text)
module function_definition identifier parameters identifier identifier identifier identifier block if_statement not_operator attribute identifier identifier block return_statement expression_statement assignment identifier attribute attribute identifier identifier identifier if_statement comparison_operator identifier none block return_statement expression_statement assignment pattern_list identifier identifier identifier if_statement comparison_operator identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier else_clause block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier binary_operator string string_start string_content string_end tuple identifier identifier expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier
This callback is called when the main window is zoomed.
def start_of_day(self) -> datetime: self.value = datetime(self.value.year, self.value.month, self.value.day) return self.value
module function_definition identifier parameters identifier type identifier block expression_statement assignment attribute identifier identifier call identifier argument_list attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier return_statement attribute identifier identifier
Returns start of day
def _find_special(self): charnames = self._get_char_names() for eventdir in glob.glob('/sys/class/input/event*'): char_name = os.path.split(eventdir)[1] if char_name in charnames: continue name_file = os.path.join(eventdir, 'device', 'name') with open(name_file) as name_file: device_name = name_file.read().strip() if device_name in self.codes['specials']: self._parse_device_path( self.codes['specials'][device_name], os.path.join('/dev/input', char_name))
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list for_statement identifier call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier subscript call attribute attribute identifier identifier identifier argument_list identifier integer if_statement comparison_operator identifier identifier block continue_statement expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end string string_start string_content string_end with_statement with_clause with_item as_pattern call identifier argument_list identifier as_pattern_target identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list if_statement comparison_operator identifier subscript attribute identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list subscript subscript attribute identifier identifier string string_start string_content string_end identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier
Look for special devices.
def _set_config(c): func = sdl2.SDL_GL_SetAttribute func(sdl2.SDL_GL_RED_SIZE, c['red_size']) func(sdl2.SDL_GL_GREEN_SIZE, c['green_size']) func(sdl2.SDL_GL_BLUE_SIZE, c['blue_size']) func(sdl2.SDL_GL_ALPHA_SIZE, c['alpha_size']) func(sdl2.SDL_GL_DEPTH_SIZE, c['depth_size']) func(sdl2.SDL_GL_STENCIL_SIZE, c['stencil_size']) func(sdl2.SDL_GL_DOUBLEBUFFER, 1 if c['double_buffer'] else 0) samps = c['samples'] func(sdl2.SDL_GL_MULTISAMPLEBUFFERS, 1 if samps > 0 else 0) func(sdl2.SDL_GL_MULTISAMPLESAMPLES, samps if samps > 0 else 0) func(sdl2.SDL_GL_STEREO, c['stereo'])
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier expression_statement call identifier argument_list attribute identifier identifier subscript identifier string string_start string_content string_end expression_statement call identifier argument_list attribute identifier identifier subscript identifier string string_start string_content string_end expression_statement call identifier argument_list attribute identifier identifier subscript identifier string string_start string_content string_end expression_statement call identifier argument_list attribute identifier identifier subscript identifier string string_start string_content string_end expression_statement call identifier argument_list attribute identifier identifier subscript identifier string string_start string_content string_end expression_statement call identifier argument_list attribute identifier identifier subscript identifier string string_start string_content string_end expression_statement call identifier argument_list attribute identifier identifier conditional_expression integer subscript identifier string string_start string_content string_end integer expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement call identifier argument_list attribute identifier identifier conditional_expression integer comparison_operator identifier integer integer expression_statement call identifier argument_list attribute identifier identifier conditional_expression identifier comparison_operator identifier integer integer expression_statement call identifier argument_list attribute identifier identifier subscript identifier string string_start string_content string_end
Set gl configuration for SDL2
def IsRunning(self): current_urn = self.Get(self.Schema.CURRENT_FLOW_URN) if not current_urn: return False try: current_flow = aff4.FACTORY.Open( urn=current_urn, aff4_type=flow.GRRFlow, token=self.token, mode="r") except aff4.InstantiationError: logging.error("Unable to open cron job run: %s", current_urn) self.DeleteAttribute(self.Schema.CURRENT_FLOW_URN) self.Flush() return False return current_flow.GetRunner().IsRunning()
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute attribute identifier identifier identifier if_statement not_operator identifier block return_statement false try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier string string_start string_content string_end except_clause attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list attribute attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list return_statement false return_statement call attribute call attribute identifier identifier argument_list identifier argument_list
Returns True if there's a currently running iteration of this job.
def to_dict(self): return dict( raw=self.raw, scheme=self.scheme, authority=self.authority, netloc=self.authority, path=self.path, query=self.query, fragment=self.fragment, userinfo=self.userinfo, username=self.username, password=self.password, host=self.host, hostname=self.hostname, port=self.port, resource=self.resource, url=self.url, encoding=self.encoding, )
module function_definition identifier parameters identifier block return_statement call identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier
Return a dict of the attributes.
def build(self, **values: Any) -> str: converted_values = { key: self._converters[key].to_url(value) for key, value in values.items() if key in self._converters } result = self._builder.format(**converted_values).split('|', 1)[1] query_string = urlencode( { key: value for key, value in values.items() if key not in self._converters and key not in self.defaults }, doseq=True, ) if query_string: result = "{}?{}".format(result, query_string) return result
module function_definition identifier parameters identifier typed_parameter dictionary_splat_pattern identifier type identifier type identifier block expression_statement assignment identifier dictionary_comprehension pair identifier call attribute subscript attribute identifier identifier identifier identifier argument_list identifier for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list if_clause comparison_operator identifier attribute identifier identifier expression_statement assignment identifier subscript call attribute call attribute attribute identifier identifier identifier argument_list dictionary_splat identifier identifier argument_list string string_start string_content string_end integer integer expression_statement assignment identifier call identifier argument_list dictionary_comprehension pair identifier identifier for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list if_clause boolean_operator comparison_operator identifier attribute identifier identifier comparison_operator identifier attribute identifier identifier keyword_argument identifier true if_statement identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier identifier return_statement identifier
Build this rule into a path using the values given.
def start(self): self.thread_handler.run(target=self.start_blocking) self.thread_handler.start_run_loop()
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list
Start the MQTT client.
def slew(self, value): if float(value) != self.filepos: pos = float(value) * self.filesize self.mlog.f.seek(int(pos)) self.find_message()
module function_definition identifier parameters identifier identifier block if_statement comparison_operator call identifier argument_list identifier attribute identifier identifier block expression_statement assignment identifier binary_operator call identifier argument_list identifier attribute identifier identifier expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list
move to a given position in the file
def jsonify_log_record(self, log_record): return self.json_serializer(log_record, default=self.json_default, cls=self.json_encoder, indent=self.json_indent, ensure_ascii=self.json_ensure_ascii)
module function_definition identifier parameters identifier identifier block return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier
Returns a json string of the log record.
def handle_data(self, context, data, dt): if self.rule.should_trigger(dt): self.callback(context, data)
module function_definition identifier parameters identifier identifier identifier identifier block if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier identifier
Calls the callable only when the rule is triggered.
def bytes_to_str(s, encoding='utf-8'): if six.PY3 and isinstance(s, bytes): return s.decode(encoding) return s
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end block if_statement boolean_operator attribute identifier identifier call identifier argument_list identifier identifier block return_statement call attribute identifier identifier argument_list identifier return_statement identifier
Returns a str if a bytes object is given.
def add_command(self, command, function, description=None): super(Program, self).add_command(command, function, description) self.service.register(command, function)
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none block expression_statement call attribute call identifier argument_list identifier identifier identifier argument_list identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier
Register a new function for command