code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def _rename_duplicate_tabs(self, current, name, path): for i in range(self.count()): if self.widget(i)._tab_name == name and self.widget(i) != current: file_path = self.widget(i).file.path if file_path: parent_dir = os.path.split(os.path.abspath( os.path.join(file_path, os.pardir)))[1] new_name = os.path.join(parent_dir, name) self.setTabText(i, new_name) self.widget(i)._tab_name = new_name break if path: parent_dir = os.path.split(os.path.abspath( os.path.join(path, os.pardir)))[1] return os.path.join(parent_dir, name) else: return name
module function_definition identifier parameters identifier identifier identifier identifier block for_statement identifier call identifier argument_list call attribute identifier identifier argument_list block if_statement boolean_operator comparison_operator attribute call attribute identifier identifier argument_list identifier identifier identifier comparison_operator call attribute identifier identifier argument_list identifier identifier block expression_statement assignment identifier attribute attribute call attribute identifier identifier argument_list identifier identifier identifier if_statement identifier block expression_statement assignment identifier subscript call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier attribute identifier identifier integer expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement assignment attribute call attribute identifier identifier argument_list identifier identifier identifier break_statement if_statement identifier block expression_statement assignment identifier subscript call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier attribute identifier identifier integer return_statement call attribute attribute identifier identifier identifier argument_list identifier identifier else_clause block return_statement identifier
Rename tabs whose title is the same as the name
async def load(self, node_id=None): if node_id is not None: await self._load_node(node_id=node_id) else: await self._load_all_nodes()
module function_definition identifier parameters identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement await call attribute identifier identifier argument_list keyword_argument identifier identifier else_clause block expression_statement await call attribute identifier identifier argument_list
Load nodes from KLF 200, if no node_id is specified all nodes are loaded.
def initialize_axes(self, boundary=0.05): bs = [(self.vals[:, i].max()-self.vals[:, i].min())*boundary for i in range(3)] self.x_lim = np.array([self.vals[:, 0].min()-bs[0], self.vals[:, 0].max()+bs[0]]) self.y_lim = np.array([self.vals[:, 1].min()-bs[1], self.vals[:, 1].max()+bs[1]]) self.z_lim = np.array([self.vals[:, 2].min()-bs[2], self.vals[:, 2].max()+bs[2]])
module function_definition identifier parameters identifier default_parameter identifier float block expression_statement assignment identifier list_comprehension binary_operator parenthesized_expression binary_operator call attribute subscript attribute identifier identifier slice identifier identifier argument_list call attribute subscript attribute identifier identifier slice identifier identifier argument_list identifier for_in_clause identifier call identifier argument_list integer expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list list binary_operator call attribute subscript attribute identifier identifier slice integer identifier argument_list subscript identifier integer binary_operator call attribute subscript attribute identifier identifier slice integer identifier argument_list subscript identifier integer expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list list binary_operator call attribute subscript attribute identifier identifier slice integer identifier argument_list subscript identifier integer binary_operator call attribute subscript attribute identifier identifier slice integer identifier argument_list subscript identifier integer expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list list binary_operator call attribute subscript attribute identifier identifier slice integer identifier argument_list subscript identifier integer binary_operator call attribute subscript attribute identifier identifier slice integer identifier argument_list subscript identifier integer
Set up the axes with the right limits and scaling.
def _EnsureRequesterStarted(self): if not self._analyzer_started: self._analyzer.start() self._analyzer_started = True
module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier true
Checks if the analyzer is running and starts it if not.
def delete(self, event): assert self.receiver_id == event.receiver_id event.response = {'status': 410, 'message': 'Gone.'} event.response_code = 410
module function_definition identifier parameters identifier identifier block assert_statement comparison_operator attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier dictionary pair string string_start string_content string_end integer pair string string_start string_content string_end string string_start string_content string_end expression_statement assignment attribute identifier identifier integer
Mark event as deleted.
def render(self, *args, **kwargs): return self.doctype.render() + super().render(*args, **kwargs)
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block return_statement binary_operator call attribute attribute identifier identifier identifier argument_list call attribute call identifier argument_list identifier argument_list list_splat identifier dictionary_splat identifier
Override so each html page served have a doctype
def ajax_get_service(self): uid = self.request.form.get("uid", None) if uid is None: return self.error("Invalid UID", status=400) service = self.get_object_by_uid(uid) if not service: return self.error("Service not found", status=404) info = self.get_service_info(service) return info
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end none if_statement comparison_operator identifier none block return_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement not_operator identifier block return_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement identifier
Returns the services information
def Sign(self, message, use_pss=False): precondition.AssertType(message, bytes) if not use_pss: padding_algorithm = padding.PKCS1v15() else: padding_algorithm = padding.PSS( mgf=padding.MGF1(hashes.SHA256()), salt_length=padding.PSS.MAX_LENGTH) return self._value.sign(message, padding_algorithm, hashes.SHA256())
module function_definition identifier parameters identifier identifier default_parameter identifier false block expression_statement call attribute identifier identifier argument_list identifier identifier if_statement not_operator identifier block expression_statement assignment identifier call attribute identifier identifier argument_list else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier attribute attribute identifier identifier identifier return_statement call attribute attribute identifier identifier identifier argument_list identifier identifier call attribute identifier identifier argument_list
Sign a given message.
def _set_zone_name(self, zoneid, name): zoneid -= 1 data = { '_set_zone_name': 'Set Name', 'select_zone': str(zoneid), 'zone_name': name, } self._controller.post(data)
module function_definition identifier parameters identifier identifier identifier block expression_statement augmented_assignment identifier integer expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end call identifier argument_list identifier pair string string_start string_content string_end identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Private method to override zone name.
def _context_string(context): msg = 'Code block context:\n ' lines = ['Selective arithmetic coding bypass: {0}', 'Reset context probabilities on coding pass boundaries: {1}', 'Termination on each coding pass: {2}', 'Vertically stripe causal context: {3}', 'Predictable termination: {4}', 'Segmentation symbols: {5}'] msg += '\n '.join(lines) msg = msg.format(((context & 0x01) > 0), ((context & 0x02) > 0), ((context & 0x04) > 0), ((context & 0x08) > 0), ((context & 0x10) > 0), ((context & 0x20) > 0)) return msg
module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_content escape_sequence string_end expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement augmented_assignment identifier call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list parenthesized_expression comparison_operator parenthesized_expression binary_operator identifier integer integer parenthesized_expression comparison_operator parenthesized_expression binary_operator identifier integer integer parenthesized_expression comparison_operator parenthesized_expression binary_operator identifier integer integer parenthesized_expression comparison_operator parenthesized_expression binary_operator identifier integer integer parenthesized_expression comparison_operator parenthesized_expression binary_operator identifier integer integer parenthesized_expression comparison_operator parenthesized_expression binary_operator identifier integer integer return_statement identifier
Produce a string to represent the code block context
def _fetchAllChildren(self): childItems = [] if self._array.ndim == 2: _nRows, nCols = self._array.shape if self._array is not None else (0, 0) for col in range(nCols): colItem = SliceRti(self._array[:, col], nodeName="channel-{}".format(col), fileName=self.fileName, iconColor=self.iconColor, attributes=self.attributes) childItems.append(colItem) return childItems
module function_definition identifier parameters identifier block expression_statement assignment identifier list if_statement comparison_operator attribute attribute identifier identifier identifier integer block expression_statement assignment pattern_list identifier identifier conditional_expression attribute attribute identifier identifier identifier comparison_operator attribute identifier identifier none tuple integer integer for_statement identifier call identifier argument_list identifier block expression_statement assignment identifier call identifier argument_list subscript attribute identifier identifier slice identifier keyword_argument identifier call attribute string string_start string_content string_end identifier argument_list identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Adds an ArrayRti per column as children so that they can be inspected easily
def _compile_literal(self, data): if data is None: return 'nil' elif data is True: return 'yes' elif data is False: return 'no' else: return repr(data)
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier none block return_statement string string_start string_content string_end elif_clause comparison_operator identifier true block return_statement string string_start string_content string_end elif_clause comparison_operator identifier false block return_statement string string_start string_content string_end else_clause block return_statement call identifier argument_list identifier
Write correct representation of literal.
def delaunay_2d(self, tol=1e-05, alpha=0.0, offset=1.0, bound=False, inplace=False): alg = vtk.vtkDelaunay2D() alg.SetProjectionPlaneMode(vtk.VTK_BEST_FITTING_PLANE) alg.SetInputDataObject(self) alg.SetTolerance(tol) alg.SetAlpha(alpha) alg.SetOffset(offset) alg.SetBoundingTriangulation(bound) alg.Update() mesh = _get_output(alg) if inplace: self.overwrite(mesh) else: return mesh
module function_definition identifier parameters identifier default_parameter identifier float default_parameter identifier float default_parameter identifier float default_parameter identifier false default_parameter identifier false block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier else_clause block return_statement identifier
Apply a delaunay 2D filter along the best fitting plane
def print_descr(rect, annot): annot.parent.insertText(rect.br + (10, 0), "'%s' annotation" % annot.type[1], color = red)
module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator attribute identifier identifier tuple integer integer binary_operator string string_start string_content string_end subscript attribute identifier identifier integer keyword_argument identifier identifier
Print a short description to the right of an annot rect.
def ssh_calc_aws(node): userlu = {"ubunt": "ubuntu", "debia": "admin", "fedor": "root", "cento": "centos", "openb": "root"} image_name = node.driver.get_image(node.extra['image_id']).name if not image_name: image_name = node.name usertemp = ['name'] + [value for key, value in list(userlu.items()) if key in image_name.lower()] usertemp = dict(zip(usertemp[::2], usertemp[1::2])) username = usertemp.get('name', 'ec2-user') return username
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier attribute call attribute attribute identifier identifier identifier argument_list subscript attribute identifier identifier string string_start string_content string_end identifier if_statement not_operator identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier binary_operator list string string_start string_content string_end list_comprehension identifier for_in_clause pattern_list identifier identifier call identifier argument_list call attribute identifier identifier argument_list if_clause comparison_operator identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list call identifier argument_list subscript identifier slice integer subscript identifier slice integer integer expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end return_statement identifier
Calculate default ssh-user based on image-if of AWS instance.
def team_info(): teams = __get_league_object().find('teams').findall('team') output = [] for team in teams: info = {} for x in team.attrib: info[x] = team.attrib[x] output.append(info) return output
module function_definition identifier parameters block expression_statement assignment identifier call attribute call attribute call identifier argument_list identifier argument_list string string_start string_content string_end identifier argument_list string string_start string_content string_end expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment identifier dictionary for_statement identifier attribute identifier identifier block expression_statement assignment subscript identifier identifier subscript attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Returns a list of team information dictionaries
def preview(num): problem_text = Problem(num).text click.secho("Project Euler Problem %i" % num, bold=True) click.echo(problem_text)
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute call identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier keyword_argument identifier true expression_statement call attribute identifier identifier argument_list identifier
Prints the text of a problem.
def full_path(self): if self.parent: return os.path.join(self.parent.full_path, self.name) return self.name
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block return_statement call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier attribute identifier identifier return_statement attribute identifier identifier
Absolute system path to the node
def _match_iter_single(self, path_elements, start_at): length = len(path_elements) if length == 0: return if self.bound_end: start = length - 1 if start < start_at: return else: start = start_at if self.bound_start: end = 1 else: end = length if start > end: return for index in range(start, end): element = path_elements[index] if self.elements[0].match(element): yield index + 1
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier integer block return_statement if_statement attribute identifier identifier block expression_statement assignment identifier binary_operator identifier integer if_statement comparison_operator identifier identifier block return_statement else_clause block expression_statement assignment identifier identifier if_statement attribute identifier identifier block expression_statement assignment identifier integer else_clause block expression_statement assignment identifier identifier if_statement comparison_operator identifier identifier block return_statement for_statement identifier call identifier argument_list identifier identifier block expression_statement assignment identifier subscript identifier identifier if_statement call attribute subscript attribute identifier identifier integer identifier argument_list identifier block expression_statement yield binary_operator identifier integer
Implementation of match_iter optimized for self.elements of length 1
def lookup_forward(name): ip_addresses = {} addresses = list(set(str(ip[4][0]) for ip in socket.getaddrinfo( name, None))) if addresses is None: return ip_addresses for address in addresses: if type(ipaddress.ip_address(address)) is ipaddress.IPv4Address: ip_addresses['ipv4'] = address if type(ipaddress.ip_address(address)) is ipaddress.IPv6Address: ip_addresses['ipv6'] = address return ip_addresses
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary expression_statement assignment identifier call identifier argument_list call identifier generator_expression call identifier argument_list subscript subscript identifier integer integer for_in_clause identifier call attribute identifier identifier argument_list identifier none if_statement comparison_operator identifier none block return_statement identifier for_statement identifier identifier block if_statement comparison_operator call identifier argument_list call attribute identifier identifier argument_list identifier attribute identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end identifier if_statement comparison_operator call identifier argument_list call attribute identifier identifier argument_list identifier attribute identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end identifier return_statement identifier
Perform a forward lookup of a hostname.
def formatted_value(self): val = self.value pval = val ftype = self.value_type if ftype == "percentage": pval = int(round(val * 100)) if self.type == "negative": pval = 0 - (100 - pval) else: pval -= 100 elif ftype == "additive_percentage": pval = int(round(val * 100)) elif ftype == "inverted_percentage": pval = 100 - int(round(val * 100)) if self.type == "negative": if self.value > 1: pval = 0 - pval elif ftype == "additive" or ftype == "particle_index" or ftype == "account_id": if int(val) == val: pval = int(val) elif ftype == "date": d = time.gmtime(int(val)) pval = time.strftime("%Y-%m-%d %H:%M:%S", d) return u"{0}".format(pval)
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier identifier expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list call identifier argument_list binary_operator identifier integer if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier binary_operator integer parenthesized_expression binary_operator integer identifier else_clause block expression_statement augmented_assignment identifier integer elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list call identifier argument_list binary_operator identifier integer elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier binary_operator integer call identifier argument_list call identifier argument_list binary_operator identifier integer if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block if_statement comparison_operator attribute identifier identifier integer block expression_statement assignment identifier binary_operator integer identifier elif_clause boolean_operator boolean_operator comparison_operator identifier string string_start string_content string_end comparison_operator identifier string string_start string_content string_end comparison_operator identifier string string_start string_content string_end block if_statement comparison_operator call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list identifier elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement call attribute string string_start string_content string_end identifier argument_list identifier
Returns a formatted value as a string
def _remove_n(self): for i, result in enumerate(self.results): largest = max(str(result).split('N'), key=len) start = result.locate(largest)[0][0] stop = start + len(largest) if start != stop: self.results[i] = self.results[i][start:stop]
module function_definition identifier parameters identifier block for_statement pattern_list identifier identifier call identifier argument_list attribute identifier identifier block expression_statement assignment identifier call identifier argument_list call attribute call identifier argument_list identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier expression_statement assignment identifier subscript subscript call attribute identifier identifier argument_list identifier integer integer expression_statement assignment identifier binary_operator identifier call identifier argument_list identifier if_statement comparison_operator identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier subscript subscript attribute identifier identifier identifier slice identifier identifier
Remove terminal Ns from sequencing results.
def powernode_data(self, name:str) -> Powernode: self.assert_powernode(name) contained_nodes = frozenset(self.nodes_in(name)) return Powernode( size=len(contained_nodes), contained=frozenset(self.all_in(name)), contained_pnodes=frozenset(self.powernodes_in(name)), contained_nodes=contained_nodes, )
module function_definition identifier parameters identifier typed_parameter identifier type identifier type identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list identifier return_statement call identifier argument_list keyword_argument identifier call identifier argument_list identifier keyword_argument identifier call identifier argument_list call attribute identifier identifier argument_list identifier keyword_argument identifier call identifier argument_list call attribute identifier identifier argument_list identifier keyword_argument identifier identifier
Return a Powernode object describing the given powernode
def _call_syndic(self, func, args=(), kwargs=None, master_id=None): if kwargs is None: kwargs = {} successful = False for master, syndic_future in self.iter_master_options(master_id): if not syndic_future.done() or syndic_future.exception(): log.error( 'Unable to call %s on %s, that syndic is not connected', func, master ) continue try: getattr(syndic_future.result(), func)(*args, **kwargs) successful = True except SaltClientError: log.error( 'Unable to call %s on %s, trying another...', func, master ) self._mark_master_dead(master) if not successful: log.critical('Unable to call %s on any masters!', func)
module function_definition identifier parameters identifier identifier default_parameter identifier tuple default_parameter identifier none default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier dictionary expression_statement assignment identifier false for_statement pattern_list identifier identifier call attribute identifier identifier argument_list identifier block if_statement boolean_operator not_operator call attribute identifier identifier argument_list call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier continue_statement try_statement block expression_statement call call identifier argument_list call attribute identifier identifier argument_list identifier argument_list list_splat identifier dictionary_splat identifier expression_statement assignment identifier true except_clause identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier expression_statement call attribute identifier identifier argument_list identifier if_statement not_operator identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier
Wrapper to call a given func on a syndic, best effort to get the one you asked for
def _ParseYamlFromFile(filedesc): content = filedesc.read() return yaml.Parse(content) or collections.OrderedDict()
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list return_statement boolean_operator call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list
Parses given YAML file.
def construct_url(self): path = [self.path] path.extend([str(x) for x in self.params]) url = self.client.base_url + '/'.join(x for x in path if x) query = self.kwargs.get('query') if query: if type(query) is dict: query = query.items() query = [ (k, v) for (k, v) in query if v is not None ] url += '?' + urlencode(query) return url
module function_definition identifier parameters identifier block expression_statement assignment identifier list attribute identifier identifier expression_statement call attribute identifier identifier argument_list list_comprehension call identifier argument_list identifier for_in_clause identifier attribute identifier identifier expression_statement assignment identifier binary_operator attribute attribute identifier identifier identifier call attribute string string_start string_content string_end identifier generator_expression identifier for_in_clause identifier identifier if_clause identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end if_statement identifier block if_statement comparison_operator call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier list_comprehension tuple identifier identifier for_in_clause tuple_pattern identifier identifier identifier if_clause comparison_operator identifier none expression_statement augmented_assignment identifier binary_operator string string_start string_content string_end call identifier argument_list identifier return_statement identifier
Construct a full plex request URI, with `params`.
def save_block(self, data, dest): write_csv(dest, data, self.sep, self.fmt, 'no-header')
module function_definition identifier parameters identifier identifier identifier block expression_statement call identifier argument_list identifier identifier attribute identifier identifier attribute identifier identifier string string_start string_content string_end
Save data on dest, which is file open in 'a' mode
def create_equipamento(self): return Equipamento( self.networkapi_url, self.user, self.password, self.user_ldap)
module function_definition identifier parameters identifier block return_statement call identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier
Get an instance of equipamento services facade.
def _file_name(self, dtype_out_time, extension='nc'): if dtype_out_time is None: dtype_out_time = '' out_lbl = utils.io.data_out_label(self.intvl_out, dtype_out_time, dtype_vert=self.dtype_out_vert) in_lbl = utils.io.data_in_label(self.intvl_in, self.dtype_in_time, self.dtype_in_vert) start_year = utils.times.infer_year(self.start_date) end_year = utils.times.infer_year(self.end_date) yr_lbl = utils.io.yr_label((start_year, end_year)) return '.'.join( [self.name, out_lbl, in_lbl, self.model.name, self.run.name, yr_lbl, extension] ).replace('..', '.')
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end block if_statement comparison_operator identifier none block expression_statement assignment identifier string string_start string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier keyword_argument identifier attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list tuple identifier identifier return_statement call attribute call attribute string string_start string_content string_end identifier argument_list list attribute identifier identifier identifier identifier attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end
Create the name of the aospy file.
def MakeRequest(self, data): stats_collector_instance.Get().IncrementCounter("grr_client_sent_bytes", len(data)) response = self.http_manager.OpenServerEndpoint( path="control?api=%s" % config.CONFIG["Network.api"], verify_cb=self.VerifyServerControlResponse, data=data, headers={"Content-Type": "binary/octet-stream"}) if response.code == 406: self.InitiateEnrolment() return response if response.code == 200: stats_collector_instance.Get().IncrementCounter( "grr_client_received_bytes", len(response.data)) return response return response
module function_definition identifier parameters identifier identifier block expression_statement call attribute call attribute identifier identifier argument_list identifier argument_list string string_start string_content string_end call identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier binary_operator string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier dictionary pair string string_start string_content string_end string string_start string_content string_end if_statement comparison_operator attribute identifier identifier integer block expression_statement call attribute identifier identifier argument_list return_statement identifier if_statement comparison_operator attribute identifier identifier integer block expression_statement call attribute call attribute identifier identifier argument_list identifier argument_list string string_start string_content string_end call identifier argument_list attribute identifier identifier return_statement identifier return_statement identifier
Make a HTTP Post request to the server 'control' endpoint.
def _step_failure(self, exc): self.log_crit(u"STEP %d (%s) FAILURE" % (self.step_index, self.step_label)) self.step_index += 1 self.log_exc(u"Unexpected error while executing task", exc, True, ExecuteTaskExecutionError)
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple attribute identifier identifier attribute identifier identifier expression_statement augmented_assignment attribute identifier identifier integer expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier true identifier
Log failure of a step
def entity_tags_form(self, entity, ns=None): if ns is None: ns = self.entity_default_ns(entity) field = TagsField(label=_l("Tags"), ns=ns) cls = type("EntityNSTagsForm", (_TagsForm,), {"tags": field}) return cls
module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier call identifier argument_list string string_start string_content string_end keyword_argument identifier identifier expression_statement assignment identifier call identifier argument_list string string_start string_content string_end tuple identifier dictionary pair string string_start string_content string_end identifier return_statement identifier
Construct a form class with a field for tags in namespace `ns`.
def setViewMode( self, state = True ): if self._viewMode == state: return self._viewMode = state if state: self._mainView.setDragMode( self._mainView.ScrollHandDrag ) else: self._mainView.setDragMode( self._mainView.RubberBandDrag ) self.emitViewModeChanged()
module function_definition identifier parameters identifier default_parameter identifier true block if_statement comparison_operator attribute identifier identifier identifier block return_statement expression_statement assignment attribute identifier identifier identifier if_statement identifier block expression_statement call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list
Starts the view mode for moving around the scene.
def data_type_to_numpy(datatype, unsigned=False): basic_type = _dtypeLookup[datatype] if datatype in (stream.STRING, stream.OPAQUE): return np.dtype(basic_type) if unsigned: basic_type = basic_type.replace('i', 'u') return np.dtype('=' + basic_type)
module function_definition identifier parameters identifier default_parameter identifier false block expression_statement assignment identifier subscript identifier identifier if_statement comparison_operator identifier tuple attribute identifier identifier attribute identifier identifier block return_statement call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end return_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier
Convert an ncstream datatype to a numpy one.
def getCiphertextLen(self, ciphertext): plaintext_length = self.getPlaintextLen(ciphertext) ciphertext_length = plaintext_length + Encrypter._CTXT_EXPANSION return ciphertext_length
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier binary_operator identifier attribute identifier identifier return_statement identifier
Given a ``ciphertext`` with a valid header, returns the length of the ciphertext inclusive of ciphertext expansion.
def to_jd(year, month, day, method=None): method = method or 'equinox' if day < 1 or day > 30: raise ValueError("Invalid day for this calendar") if month > 13: raise ValueError("Invalid month for this calendar") if month == 13 and day > 5 + leap(year, method=method): raise ValueError("Invalid day for this month in this calendar") if method == 'equinox': return _to_jd_equinox(year, month, day) else: return _to_jd_schematic(year, month, day, method)
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none block expression_statement assignment identifier boolean_operator identifier string string_start string_content string_end if_statement boolean_operator comparison_operator identifier integer comparison_operator identifier integer block raise_statement call identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier integer block raise_statement call identifier argument_list string string_start string_content string_end if_statement boolean_operator comparison_operator identifier integer comparison_operator identifier binary_operator integer call identifier argument_list identifier keyword_argument identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier string string_start string_content string_end block return_statement call identifier argument_list identifier identifier identifier else_clause block return_statement call identifier argument_list identifier identifier identifier identifier
Obtain Julian day from a given French Revolutionary calendar date.
def _execute_comprehension(self, node: Union[ast.ListComp, ast.SetComp, ast.GeneratorExp, ast.DictComp]) -> Any: args = [ast.arg(arg=name) for name in sorted(self._name_to_value.keys())] func_def_node = ast.FunctionDef( name="generator_expr", args=ast.arguments(args=args, kwonlyargs=[], kw_defaults=[], defaults=[]), decorator_list=[], body=[ast.Return(node)]) module_node = ast.Module(body=[func_def_node]) ast.fix_missing_locations(module_node) code = compile(source=module_node, filename='<ast>', mode='exec') module_locals = {} module_globals = {} exec(code, module_globals, module_locals) generator_expr_func = module_locals["generator_expr"] return generator_expr_func(**self._name_to_value)
module function_definition identifier parameters identifier typed_parameter identifier type generic_type identifier type_parameter type attribute identifier identifier type attribute identifier identifier type attribute identifier identifier type attribute identifier identifier type identifier block expression_statement assignment identifier list_comprehension call attribute identifier identifier argument_list keyword_argument identifier identifier for_in_clause identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier list keyword_argument identifier list keyword_argument identifier list keyword_argument identifier list keyword_argument identifier list call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement assignment identifier dictionary expression_statement assignment identifier dictionary expression_statement call identifier argument_list identifier identifier identifier expression_statement assignment identifier subscript identifier string string_start string_content string_end return_statement call identifier argument_list dictionary_splat attribute identifier identifier
Compile the generator or comprehension from the node and execute the compiled code.
def _call_in_reactor_thread(self, f, *args, **kwargs): self._reactor.callFromThread(f, *args, **kwargs)
module function_definition identifier parameters identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier list_splat identifier dictionary_splat identifier
Call the given function with args in the reactor thread.
def geturl(self): return urlparse.urlunparse(( self.scheme, self.netloc, self.path, self.params, self.query_str, self.fragment, ))
module function_definition identifier parameters identifier block return_statement call attribute identifier identifier argument_list tuple attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier
return the dsn back into url form
async def get_constants(self): url = self.BASE + '/constants' data = await self.request(url) return Constants(self, data)
module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier await call attribute identifier identifier argument_list identifier return_statement call identifier argument_list identifier identifier
Get clash royale constants.
def restart(ctx, **kwargs): update_context(ctx, kwargs) daemon = mk_daemon(ctx) daemon.stop() daemon.start()
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement call identifier argument_list identifier identifier 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
restart a vaping process
def init(cls, name): clsdict = {subcls.name: subcls for subcls in cls.__subclasses__() if hasattr(subcls, 'name')} return clsdict.get(name, cls)(name)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary_comprehension pair attribute identifier identifier identifier for_in_clause identifier call attribute identifier identifier argument_list if_clause call identifier argument_list identifier string string_start string_content string_end return_statement call call attribute identifier identifier argument_list identifier identifier argument_list identifier
Return an instance of this class or an appropriate subclass
def replace(self, p_todos): self.erase() self.add_todos(p_todos) self.dirty = True
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier true
Replaces whole todolist with todo objects supplied as p_todos.
def xpathNewContext(self): ret = libxml2mod.xmlXPathNewContext(self._o) if ret is None:raise xpathError('xmlXPathNewContext() failed') __tmp = xpathContext(_obj=ret) return __tmp
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier if_statement comparison_operator identifier none block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier return_statement identifier
Create a new xmlXPathContext
def parse_pdb_file(self): self.pdb_parse_tree = {'info': {}, 'data': { self.state: {}} } try: for line in self.pdb_lines: self.current_line = line record_name = line[:6].strip() if record_name in self.proc_functions: self.proc_functions[record_name]() else: if record_name not in self.pdb_parse_tree['info']: self.pdb_parse_tree['info'][record_name] = [] self.pdb_parse_tree['info'][record_name].append(line) except EOFError: pass if self.new_labels: ampal_data_session.commit() return
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier dictionary pair string string_start string_content string_end dictionary pair string string_start string_content string_end dictionary pair attribute identifier identifier dictionary try_statement block for_statement identifier attribute identifier identifier block expression_statement assignment attribute identifier identifier identifier expression_statement assignment identifier call attribute subscript identifier slice integer identifier argument_list if_statement comparison_operator identifier attribute identifier identifier block expression_statement call subscript attribute identifier identifier identifier argument_list else_clause block if_statement comparison_operator identifier subscript attribute identifier identifier string string_start string_content string_end block expression_statement assignment subscript subscript attribute identifier identifier string string_start string_content string_end identifier list expression_statement call attribute subscript subscript attribute identifier identifier string string_start string_content string_end identifier identifier argument_list identifier except_clause identifier block pass_statement if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list return_statement
Runs the PDB parser.
def form_lines_valid(self, form): handled = 0 for inner_form in form: if not inner_form.cleaned_data.get(formsets.DELETION_FIELD_NAME): handled += 1 self.handle_inner_form(inner_form) self.log_and_notify_lines(handled) return http.HttpResponseRedirect(self.get_success_url())
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier integer for_statement identifier identifier block if_statement not_operator call attribute attribute identifier identifier identifier argument_list attribute identifier identifier block expression_statement augmented_assignment identifier integer expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list
Handle a valid LineFormSet.
def randrange(seq): seq = seq.copy() choose = rng().choice remove = seq.remove for x in range(len(seq)): y = choose(seq) remove(y) yield y
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier attribute call identifier argument_list identifier expression_statement assignment identifier attribute identifier identifier for_statement identifier call identifier argument_list call identifier argument_list identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement call identifier argument_list identifier expression_statement yield identifier
Yields random values from @seq until @seq is empty
def process_fields(self, fields): result = [] strip = ''.join(self.PREFIX_MAP) for field in fields: direction = self.PREFIX_MAP[''] if field[0] in self.PREFIX_MAP: direction = self.PREFIX_MAP[field[0]] field = field.lstrip(strip) result.append((field, direction)) return result
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list expression_statement assignment identifier call attribute string string_start string_end identifier argument_list attribute identifier identifier for_statement identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier string string_start string_end if_statement comparison_operator subscript identifier integer attribute identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier subscript identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list tuple identifier identifier return_statement identifier
Process a list of simple string field definitions and assign their order based on prefix.
def _update_range(self, response): header_value = response.headers.get('x-resource-range', '') m = re.match(r'\d+-\d+/(\d+)$', header_value) if m: self._count = int(m.group(1)) else: self._count = None
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement identifier block expression_statement assignment attribute identifier identifier call identifier argument_list call attribute identifier identifier argument_list integer else_clause block expression_statement assignment attribute identifier identifier none
Update the query count property from the `X-Resource-Range` response header
def validate(self): if self.error: return False for v in self.validators: self.error = v(self.value) if self.error: return False return True
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block return_statement false for_statement identifier attribute identifier identifier block expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier if_statement attribute identifier identifier block return_statement false return_statement true
Run the form value through the validators, and update the error field if needed
def convert_body_frame(self, phi, theta, phiDot, thetaDot, psiDot): p = phiDot - psiDot*math.sin(theta) q = math.cos(phi)*thetaDot + math.sin(phi)*psiDot*math.cos(theta) r = math.cos(phi)*psiDot*math.cos(theta) - math.sin(phi)*thetaDot return (p, q, r)
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block expression_statement assignment identifier binary_operator identifier binary_operator identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier binary_operator binary_operator call attribute identifier identifier argument_list identifier identifier binary_operator binary_operator call attribute identifier identifier argument_list identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier binary_operator binary_operator binary_operator call attribute identifier identifier argument_list identifier identifier call attribute identifier identifier argument_list identifier binary_operator call attribute identifier identifier argument_list identifier identifier return_statement tuple identifier identifier identifier
convert a set of roll rates from earth frame to body frame
def _from_dict(cls, _dict): args = {} if 'entities' in _dict: args['entities'] = [ QueryEntitiesResponseItem._from_dict(x) for x in (_dict.get('entities')) ] return cls(**args)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary 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 list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier parenthesized_expression call attribute identifier identifier argument_list string string_start string_content string_end return_statement call identifier argument_list dictionary_splat identifier
Initialize a QueryEntitiesResponse object from a json dictionary.
def cleanup_temporary_directories(self): while self.build_directories: shutil.rmtree(self.build_directories.pop()) for requirement in self.reported_requirements: requirement.remove_temporary_source() while self.eggs_links: symbolic_link = self.eggs_links.pop() if os.path.islink(symbolic_link): os.unlink(symbolic_link)
module function_definition identifier parameters identifier block while_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list while_statement attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier
Delete the build directories and any temporary directories created by pip.
def force_update(self): if self.disabled or self.terminated or not self.enabled: return for meth in self.methods: self.methods[meth]["cached_until"] = time() if self.config["debug"]: self._py3_wrapper.log("clearing cache for method {}".format(meth)) self._py3_wrapper.timeout_queue_add(self)
module function_definition identifier parameters identifier block if_statement boolean_operator boolean_operator attribute identifier identifier attribute identifier identifier not_operator attribute identifier identifier block return_statement for_statement identifier attribute identifier identifier block expression_statement assignment subscript subscript attribute identifier identifier identifier string string_start string_content string_end call identifier argument_list if_statement subscript attribute identifier identifier string string_start string_content string_end block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Forces an update of the module.
def delete_fw(self, fw_id): self.fw_id = None self.fw_name = None self.fw_created = False self.active_pol_id = None
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier false expression_statement assignment attribute identifier identifier none
Deletes the FW local attributes.
def to_param_dict(self): param_dict = {} for index, dictionary in enumerate(self.value): for key, value in dictionary.items(): param_name = '{param_name}[{index}][{key}]'.format( param_name=self.param_name, index=index, key=key) param_dict[param_name] = value return OrderedDict(sorted(param_dict.items()))
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary for_statement pattern_list identifier identifier call identifier argument_list attribute identifier identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier expression_statement assignment subscript identifier identifier identifier return_statement call identifier argument_list call identifier argument_list call attribute identifier identifier argument_list
Sorts to ensure Order is consistent for Testing
def _connect(self): self.conn = self._create_connection() spawn(self.conn.connect) self.set_nick(self.nick) self.cmd(u'USER', u'{0} 3 * {1}'.format(self.nick, self.realname))
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement call identifier argument_list attribute attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier attribute identifier identifier
Connects the bot to the server and identifies itself.
def DFS(G): if not G.vertices: raise GraphInsertError("This graph have no vertices.") color = {} pred = {} reach = {} finish = {} def DFSvisit(G, current, time): color[current] = 'grey' time += 1 reach[current] = time for vertex in G.vertices[current]: if color[vertex] == 'white': pred[vertex] = current time = DFSvisit(G, vertex, time) color[current] = 'black' time += 1 finish[current] = time return time for vertex in G.vertices: color[vertex] = 'white' pred[vertex] = None reach[vertex] = 0 finish[vertex] = 0 time = 0 for vertex in G.vertices: if color[vertex] == 'white': time = DFSvisit(G, vertex, time) vertex_data = {} for vertex in G.vertices: vertex_data[vertex] = (pred[vertex], reach[vertex], finish[vertex]) return vertex_data
module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier dictionary expression_statement assignment identifier dictionary expression_statement assignment identifier dictionary expression_statement assignment identifier dictionary function_definition identifier parameters identifier identifier identifier block expression_statement assignment subscript identifier identifier string string_start string_content string_end expression_statement augmented_assignment identifier integer expression_statement assignment subscript identifier identifier identifier for_statement identifier subscript attribute identifier identifier identifier block if_statement comparison_operator subscript identifier identifier string string_start string_content string_end block expression_statement assignment subscript identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier identifier expression_statement assignment subscript identifier identifier string string_start string_content string_end expression_statement augmented_assignment identifier integer expression_statement assignment subscript identifier identifier identifier return_statement identifier for_statement identifier attribute identifier identifier block expression_statement assignment subscript identifier identifier string string_start string_content string_end expression_statement assignment subscript identifier identifier none expression_statement assignment subscript identifier identifier integer expression_statement assignment subscript identifier identifier integer expression_statement assignment identifier integer for_statement identifier attribute identifier identifier block if_statement comparison_operator subscript identifier identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list identifier identifier identifier expression_statement assignment identifier dictionary for_statement identifier attribute identifier identifier block expression_statement assignment subscript identifier identifier tuple subscript identifier identifier subscript identifier identifier subscript identifier identifier return_statement identifier
Algorithm for depth-first searching the vertices of a graph.
def sanitizer(name, replacements=[(':','_'), ('/','_'), ('\\','_')]): for old,new in replacements: name = name.replace(old,new) return name
module function_definition identifier parameters identifier default_parameter identifier list tuple string string_start string_content string_end string string_start string_content string_end tuple string string_start string_content string_end string string_start string_content string_end tuple string string_start string_content escape_sequence string_end string string_start string_content string_end block for_statement pattern_list identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier return_statement identifier
String sanitizer to avoid problematic characters in filenames.
def setup_sighandlers(self): signal.signal(signal.SIGINT, signal.SIG_IGN) signal.signal(signal.SIGTERM, signal.SIG_IGN) signal.signal(signal.SIGPROF, self.on_sigprof) signal.signal(signal.SIGABRT, self.stop) signal.siginterrupt(signal.SIGPROF, False) signal.siginterrupt(signal.SIGABRT, False) LOGGER.debug('Signal handlers setup')
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier false expression_statement call attribute identifier identifier argument_list attribute identifier identifier false expression_statement call attribute identifier identifier argument_list string string_start string_content string_end
Setup the stats and stop signal handlers.
def _is_vis(channel): if isinstance(channel, str): return channel == '00_7' elif isinstance(channel, int): return channel == 1 else: raise ValueError('Invalid channel')
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier identifier block return_statement comparison_operator identifier string string_start string_content string_end elif_clause call identifier argument_list identifier identifier block return_statement comparison_operator identifier integer else_clause block raise_statement call identifier argument_list string string_start string_content string_end
Determine whether the given channel is a visible channel
def init_with_keytab(self): creds_opts = { 'usage': 'initiate', 'name': self._cleaned_options['principal'], } store = {} if self._cleaned_options['keytab'] != DEFAULT_KEYTAB: store['client_keytab'] = self._cleaned_options['keytab'] if self._cleaned_options['ccache'] != DEFAULT_CCACHE: store['ccache'] = self._cleaned_options['ccache'] if store: creds_opts['store'] = store creds = gssapi.creds.Credentials(**creds_opts) try: creds.lifetime except gssapi.exceptions.ExpiredCredentialsError: new_creds_opts = copy.deepcopy(creds_opts) if 'store' in new_creds_opts: new_creds_opts['store']['ccache'] = _get_temp_ccache() else: new_creds_opts['store'] = {'ccache': _get_temp_ccache()} creds = gssapi.creds.Credentials(**new_creds_opts) _store = None if self._cleaned_options['ccache'] != DEFAULT_CCACHE: _store = {'ccache': store['ccache']} creds.store(usage='initiate', store=_store, overwrite=True)
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier dictionary if_statement comparison_operator subscript attribute identifier identifier string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end if_statement comparison_operator subscript attribute identifier identifier string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end if_statement identifier block expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list dictionary_splat identifier try_statement block expression_statement attribute identifier identifier except_clause attribute attribute identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript subscript identifier string string_start string_content string_end string string_start string_content string_end call identifier argument_list else_clause block expression_statement assignment subscript identifier string string_start string_content string_end dictionary pair string string_start string_content string_end call identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list dictionary_splat identifier expression_statement assignment identifier none if_statement comparison_operator subscript attribute identifier identifier string string_start string_content string_end identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier true
Initialize credential cache with keytab
def dump(self, path): try: with open(path, "wb") as f: f.write(self.__str__().encode("utf-8")) except: pass with open(path, "wb") as f: pickle.dump(self.__data__, f)
module function_definition identifier parameters identifier identifier block try_statement block with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list call attribute call attribute identifier identifier argument_list identifier argument_list string string_start string_content string_end except_clause block pass_statement with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier
dump DictTree data to json files.
def addreadergroup(self, newgroup): hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER) if 0 != hresult: raise error( 'Failed to establish context: ' + \ SCardGetErrorMessage(hresult)) try: hresult = SCardIntroduceReaderGroup(hcontext, newgroup) if 0 != hresult: raise error( 'Unable to introduce reader group: ' + \ SCardGetErrorMessage(hresult)) else: innerreadergroups.addreadergroup(self, newgroup) finally: hresult = SCardReleaseContext(hcontext) if 0 != hresult: raise error( 'Failed to release context: ' + \ SCardGetErrorMessage(hresult))
module function_definition identifier parameters identifier identifier block expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier if_statement comparison_operator integer identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end line_continuation call identifier argument_list identifier try_statement block expression_statement assignment identifier call identifier argument_list identifier identifier if_statement comparison_operator integer identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end line_continuation call identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier identifier finally_clause block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator integer identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end line_continuation call identifier argument_list identifier
Add a reader group
def phenotype_data(self): if self._phenotype_data is None: pheno_data = {} for gsm_name, gsm in iteritems(self.gsms): tmp = {} for key, value in iteritems(gsm.metadata): if len(value) == 0: tmp[key] = np.nan elif key.startswith("characteristics_"): for i, char in enumerate(value): char = re.split(":\s+", char) char_type, char_value = [char[0], ": ".join(char[1:])] tmp[key + "." + str( i) + "." + char_type] = char_value else: tmp[key] = ",".join(value) pheno_data[gsm_name] = tmp self._phenotype_data = DataFrame(pheno_data).T return self._phenotype_data
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier dictionary for_statement pattern_list identifier identifier call identifier argument_list attribute identifier identifier block expression_statement assignment identifier dictionary for_statement pattern_list identifier identifier call identifier argument_list attribute identifier identifier block if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment subscript identifier identifier attribute identifier identifier elif_clause call attribute identifier identifier argument_list string string_start string_content string_end block for_statement pattern_list identifier identifier call identifier argument_list identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment pattern_list identifier identifier list subscript identifier integer call attribute string string_start string_content string_end identifier argument_list subscript identifier slice integer expression_statement assignment subscript identifier binary_operator binary_operator binary_operator binary_operator identifier string string_start string_content string_end call identifier argument_list identifier string string_start string_content string_end identifier identifier else_clause block expression_statement assignment subscript identifier identifier call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment subscript identifier identifier identifier expression_statement assignment attribute identifier identifier attribute call identifier argument_list identifier identifier return_statement attribute identifier identifier
Get the phenotype data for each of the sample.
def _create_path_if_not_exist(self, path): if path and not os.path.exists(path): os.makedirs(path)
module function_definition identifier parameters identifier identifier block if_statement boolean_operator identifier not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier
Creates a folders path if it doesn't exist
def iiif_info_handler(prefix=None, identifier=None, config=None, klass=None, auth=None, **args): if (not auth or degraded_request(identifier) or auth.info_authz()): if (auth): logging.debug("Authorized for image %s" % identifier) i = IIIFHandler(prefix, identifier, config, klass, auth) try: return i.image_information_response() except IIIFError as e: return i.error_response(e) elif (auth.info_authn()): abort(401) else: response = redirect(host_port_prefix( config.host, config.port, prefix) + '/' + identifier + '-deg/info.json') response.headers['Access-control-allow-origin'] = '*' return response
module function_definition identifier parameters default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none dictionary_splat_pattern identifier block if_statement parenthesized_expression boolean_operator boolean_operator not_operator identifier call identifier argument_list identifier call attribute identifier identifier argument_list block if_statement parenthesized_expression identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list identifier identifier identifier identifier identifier try_statement block return_statement call attribute identifier identifier argument_list except_clause as_pattern identifier as_pattern_target identifier block return_statement call attribute identifier identifier argument_list identifier elif_clause parenthesized_expression call attribute identifier identifier argument_list block expression_statement call identifier argument_list integer else_clause block expression_statement assignment identifier call identifier argument_list binary_operator binary_operator binary_operator call identifier argument_list attribute identifier identifier attribute identifier identifier identifier string string_start string_content string_end identifier string string_start string_content string_end expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end return_statement identifier
Handler for IIIF Image Information requests.
def _IndexedScan(self, i, max_records=None): self._ReadIndex() idx = 0 start_ts = 0 if i >= self._max_indexed: start_ts = max((0, 0), (self._index[self._max_indexed][0], self._index[self._max_indexed][1] - 1)) idx = self._max_indexed else: try: possible_idx = i - i % self.INDEX_SPACING start_ts = (max(0, self._index[possible_idx][0]), self._index[possible_idx][1] - 1) idx = possible_idx except KeyError: pass if max_records is not None: max_records += i - idx with data_store.DB.GetMutationPool() as mutation_pool: for (ts, value) in self.Scan( after_timestamp=start_ts, max_records=max_records, include_suffix=True): self._MaybeWriteIndex(idx, ts, mutation_pool) if idx >= i: yield (idx, ts, value) idx += 1
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier integer expression_statement assignment identifier integer if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier call identifier argument_list tuple integer integer tuple subscript subscript attribute identifier identifier attribute identifier identifier integer binary_operator subscript subscript attribute identifier identifier attribute identifier identifier integer integer expression_statement assignment identifier attribute identifier identifier else_clause block try_statement block expression_statement assignment identifier binary_operator identifier binary_operator identifier attribute identifier identifier expression_statement assignment identifier tuple call identifier argument_list integer subscript subscript attribute identifier identifier identifier integer binary_operator subscript subscript attribute identifier identifier identifier integer integer expression_statement assignment identifier identifier except_clause identifier block pass_statement if_statement comparison_operator identifier none block expression_statement augmented_assignment identifier binary_operator identifier identifier with_statement with_clause with_item as_pattern call attribute attribute identifier identifier identifier argument_list as_pattern_target identifier block for_statement tuple_pattern identifier identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier true block expression_statement call attribute identifier identifier argument_list identifier identifier identifier if_statement comparison_operator identifier identifier block expression_statement yield tuple identifier identifier identifier expression_statement augmented_assignment identifier integer
Scan records starting with index i.
def flatten(cls, stats): flat_children = {} for _stats in spread_stats(stats): key = (_stats.name, _stats.filename, _stats.lineno, _stats.module) try: flat_stats = flat_children[key] except KeyError: flat_stats = flat_children[key] = cls(*key) flat_stats.own_hits += _stats.own_hits flat_stats.deep_hits += _stats.deep_hits flat_stats.own_time += _stats.own_time flat_stats.deep_time += _stats.deep_time children = list(itervalues(flat_children)) return cls(stats.name, stats.filename, stats.lineno, stats.module, stats.own_hits, stats.deep_hits, stats.own_time, stats.deep_time, children)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary for_statement identifier call identifier argument_list identifier block expression_statement assignment identifier tuple attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier try_statement block expression_statement assignment identifier subscript identifier identifier except_clause identifier block expression_statement assignment identifier assignment subscript identifier identifier call identifier argument_list list_splat identifier expression_statement augmented_assignment attribute identifier identifier attribute identifier identifier expression_statement augmented_assignment attribute identifier identifier attribute identifier identifier expression_statement augmented_assignment attribute identifier identifier attribute identifier identifier expression_statement augmented_assignment attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier return_statement call identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier identifier
Makes a flat statistics from the given statistics.
def mcube(self, **kwargs): kwargs_copy = self.base_dict.copy() kwargs_copy.update(**kwargs) kwargs_copy['dataset'] = kwargs.get('dataset', self.dataset(**kwargs)) kwargs_copy['component'] = kwargs.get( 'component', self.component(**kwargs)) self._replace_none(kwargs_copy) localpath = NameFactory.mcube_format.format(**kwargs_copy) if kwargs.get('fullpath', False): return self.fullpath(localpath=localpath) return localpath
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list dictionary_splat identifier expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list dictionary_splat identifier expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list dictionary_splat identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list dictionary_splat identifier if_statement call attribute identifier identifier argument_list string string_start string_content string_end false block return_statement call attribute identifier identifier argument_list keyword_argument identifier identifier return_statement identifier
return the name of a model cube file
def _check_consistency(self): type_count = defaultdict(int) for _, section in sorted(self.sections.items()): type_count[section.section_type] += 1 if type_count[POINT_TYPE.SOMA] != 1: L.info('Have %d somas, expected 1', type_count[POINT_TYPE.SOMA])
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier for_statement pattern_list identifier identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list block expression_statement augmented_assignment subscript identifier attribute identifier identifier integer if_statement comparison_operator subscript identifier attribute identifier identifier integer block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end subscript identifier attribute identifier identifier
see if the sections have obvious errors
def reset(self, relation_name=None): if relation_name is not None: self.data_access.delete("relations", dict(name=relation_name)) else: self.data_access.delete("relations", "1=1") return self
module function_definition identifier parameters identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end call identifier argument_list keyword_argument identifier identifier else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end return_statement identifier
Reset the transfer info for a particular relation, or if none is given, for all relations.
def dmsStrToDeg(dec): sign_deg, min, sec = dec.split(':') sign = sign_deg[0:1] if sign not in ('+', '-'): sign = '+' deg = sign_deg else: deg = sign_deg[1:] dec_deg = decTimeToDeg(sign, int(deg), int(min), float(sec)) return dec_deg
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier subscript identifier slice integer integer if_statement comparison_operator identifier tuple string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier identifier else_clause block expression_statement assignment identifier subscript identifier slice integer expression_statement assignment identifier call identifier argument_list identifier call identifier argument_list identifier call identifier argument_list identifier call identifier argument_list identifier return_statement identifier
Convert a string representation of DEC into a float in degrees.
def create_delete_model(record): arn = f"arn:aws:s3:::{cloudwatch.filter_request_parameters('bucketName', record)}" LOG.debug(f'[-] Deleting Dynamodb Records. Hash Key: {arn}') data = { 'arn': arn, 'principalId': cloudwatch.get_principal(record), 'userIdentity': cloudwatch.get_user_identity(record), 'accountId': record['account'], 'eventTime': record['detail']['eventTime'], 'BucketName': cloudwatch.filter_request_parameters('bucketName', record), 'Region': cloudwatch.get_region(record), 'Tags': {}, 'configuration': {}, 'eventSource': record['detail']['eventSource'], 'version': VERSION } return CurrentS3Model(**data)
module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_content interpolation call attribute identifier identifier argument_list string string_start string_content string_end identifier string_end expression_statement call attribute identifier identifier argument_list string string_start string_content interpolation identifier string_end expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end call attribute identifier identifier argument_list identifier pair string string_start string_content string_end call attribute identifier identifier argument_list identifier 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 subscript identifier string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end identifier pair string string_start string_content string_end call attribute identifier identifier argument_list identifier pair string string_start string_content string_end dictionary pair string string_start string_content string_end dictionary pair string string_start string_content string_end subscript subscript identifier string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end identifier return_statement call identifier argument_list dictionary_splat identifier
Create an S3 model from a record.
def field_datetime_from_json(self, json_val): if type(json_val) == int: seconds = int(json_val) dt = datetime.fromtimestamp(seconds, utc) elif json_val is None: dt = None else: seconds, microseconds = [int(x) for x in json_val.split('.')] dt = datetime.fromtimestamp(seconds, utc) dt += timedelta(microseconds=microseconds) return dt
module function_definition identifier parameters identifier identifier block if_statement comparison_operator call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier elif_clause comparison_operator identifier none block expression_statement assignment identifier none else_clause block expression_statement assignment pattern_list identifier identifier list_comprehension call identifier argument_list identifier for_in_clause identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement augmented_assignment identifier call identifier argument_list keyword_argument identifier identifier return_statement identifier
Convert a UTC timestamp to a UTC datetime.
def _summarize_result(self, root_action, leaf_eot): root_board = root_action.parent.board action_detail = root_action.position_pair score = self._relative_score(root_action, leaf_eot, root_action.parent.player, root_action.parent.opponent) total_leaves = 0 mana_drain_leaves = 0 for leaf in root_action.leaves(): total_leaves += 1 if leaf.is_mana_drain: mana_drain_leaves += 1 summary = base.Summary(root_board, action_detail, score, mana_drain_leaves, total_leaves) return summary
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier expression_statement assignment identifier integer expression_statement assignment identifier integer for_statement identifier call attribute identifier identifier argument_list block expression_statement augmented_assignment identifier integer if_statement attribute identifier identifier block expression_statement augmented_assignment identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier identifier identifier return_statement identifier
Return a dict with useful information that summarizes this action.
def pauli_product(*elements: Pauli) -> Pauli: result_terms = [] for terms in product(*elements): coeff = reduce(mul, [term[1] for term in terms]) ops = (term[0] for term in terms) out = [] key = itemgetter(0) for qubit, qops in groupby(heapq.merge(*ops, key=key), key=key): res = next(qops)[1] for op in qops: pair = res + op[1] res, rescoeff = PAULI_PROD[pair] coeff *= rescoeff if res != 'I': out.append((qubit, res)) p = Pauli(((tuple(out), coeff),)) result_terms.append(p) return pauli_sum(*result_terms)
module function_definition identifier parameters typed_parameter list_splat_pattern identifier type identifier type identifier block expression_statement assignment identifier list for_statement identifier call identifier argument_list list_splat identifier block expression_statement assignment identifier call identifier argument_list identifier list_comprehension subscript identifier integer for_in_clause identifier identifier expression_statement assignment identifier generator_expression subscript identifier integer for_in_clause identifier identifier expression_statement assignment identifier list expression_statement assignment identifier call identifier argument_list integer for_statement pattern_list identifier identifier call identifier argument_list call attribute identifier identifier argument_list list_splat identifier keyword_argument identifier identifier keyword_argument identifier identifier block expression_statement assignment identifier subscript call identifier argument_list identifier integer for_statement identifier identifier block expression_statement assignment identifier binary_operator identifier subscript identifier integer expression_statement assignment pattern_list identifier identifier subscript identifier identifier expression_statement augmented_assignment identifier identifier if_statement comparison_operator identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list tuple identifier identifier expression_statement assignment identifier call identifier argument_list tuple tuple call identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement call identifier argument_list list_splat identifier
Return the product of elements of the Pauli algebra
def install_egg(self, egg_name): if not os.path.exists(self.egg_directory): os.makedirs(self.egg_directory) self.requirement_set.add_requirement( InstallRequirement.from_line(egg_name, None)) try: self.requirement_set.prepare_files(self.finder) self.requirement_set.install(['--prefix=' + self.egg_directory], []) except DistributionNotFound: self.requirement_set.requirements._keys.remove(egg_name) raise PipException()
module function_definition identifier parameters identifier identifier block if_statement not_operator call attribute attribute identifier identifier identifier argument_list attribute identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list identifier none try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list list binary_operator string string_start string_content string_end attribute identifier identifier list except_clause identifier block expression_statement call attribute attribute attribute attribute identifier identifier identifier identifier identifier argument_list identifier raise_statement call identifier argument_list
Install an egg into the egg directory
def _log_statistics(self): rows_per_second_trans = self._count_total / (self._time1 - self._time0) rows_per_second_load = self._count_transform / (self._time2 - self._time1) rows_per_second_overall = self._count_total / (self._time3 - self._time0) self._log('Number of rows processed : {0:d}'.format(self._count_total)) self._log('Number of rows transformed : {0:d}'.format(self._count_transform)) self._log('Number of rows ignored : {0:d}'.format(self._count_ignore)) self._log('Number of rows parked : {0:d}'.format(self._count_park)) self._log('Number of errors : {0:d}'.format(self._count_error)) self._log('Number of rows per second processed : {0:d}'.format(int(rows_per_second_trans))) self._log('Number of rows per second loaded : {0:d}'.format(int(rows_per_second_load))) self._log('Number of rows per second overall : {0:d}'.format(int(rows_per_second_overall)))
module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator attribute identifier identifier parenthesized_expression binary_operator attribute identifier identifier attribute identifier identifier expression_statement assignment identifier binary_operator attribute identifier identifier parenthesized_expression binary_operator attribute identifier identifier attribute identifier identifier expression_statement assignment identifier binary_operator attribute identifier identifier parenthesized_expression binary_operator attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier 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 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 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 identifier
Log statistics about the number of rows and number of rows per second.
def _flush_stack(self): output = self._postprocess_output(''.join(self.stack)) self._clear_char() self._empty_stack() if not PYTHON_2: return output else: return unicode(output)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute string string_start string_end identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list if_statement not_operator identifier block return_statement identifier else_clause block return_statement call identifier argument_list identifier
Returns the final output and resets the machine's state.
def _parse(read_method: Callable) -> HTTPResponse: response = read_method(4096) while b'HTTP/' not in response or b'\r\n\r\n' not in response: response += read_method(4096) fake_sock = _FakeSocket(response) response = HTTPResponse(fake_sock) response.begin() return response
module function_definition identifier parameters typed_parameter identifier type identifier type identifier block expression_statement assignment identifier call identifier argument_list integer while_statement boolean_operator comparison_operator string string_start string_content string_end identifier comparison_operator string string_start string_content escape_sequence escape_sequence escape_sequence escape_sequence string_end identifier block expression_statement augmented_assignment identifier call identifier argument_list integer expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list return_statement identifier
Trick to standardize the API between sockets and SSLConnection objects.
def _ExtractList(self, fields, ignores=(",",), terminators=()): extracted = [] i = 0 for i, field in enumerate(fields): if field in ignores: continue if field in terminators: break extracted.append(field.strip("".join(ignores))) if not (field.endswith(",") or set(fields[i + 1:i + 2]).intersection(ignores)): break return extracted, fields[i + 1:]
module function_definition identifier parameters identifier identifier default_parameter identifier tuple string string_start string_content string_end default_parameter identifier tuple block expression_statement assignment identifier list expression_statement assignment identifier integer for_statement pattern_list identifier identifier call identifier argument_list identifier block if_statement comparison_operator identifier identifier block continue_statement if_statement comparison_operator identifier identifier block break_statement expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list call attribute string string_start string_end identifier argument_list identifier if_statement not_operator parenthesized_expression boolean_operator call attribute identifier identifier argument_list string string_start string_content string_end call attribute call identifier argument_list subscript identifier slice binary_operator identifier integer binary_operator identifier integer identifier argument_list identifier block break_statement return_statement expression_list identifier subscript identifier slice binary_operator identifier integer
Extract a list from the given fields.
def count_elements(doc): "Counts the number of times each element is used in a document" summary = {} for el in doc.iter(): try: namespace, element_name = re.search('^{(.+)}(.+)$', el.tag).groups() except: namespace = None element_name = el.tag if not summary.has_key(namespace): summary[namespace] = {} if not summary[namespace].has_key(element_name): summary[namespace][element_name] = 1 else: summary[namespace][element_name] += 1 return summary
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier dictionary for_statement identifier call attribute identifier identifier argument_list block try_statement block expression_statement assignment pattern_list identifier identifier call attribute call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier identifier argument_list except_clause block expression_statement assignment identifier none expression_statement assignment identifier attribute identifier identifier if_statement not_operator call attribute identifier identifier argument_list identifier block expression_statement assignment subscript identifier identifier dictionary if_statement not_operator call attribute subscript identifier identifier identifier argument_list identifier block expression_statement assignment subscript subscript identifier identifier identifier integer else_clause block expression_statement augmented_assignment subscript subscript identifier identifier identifier integer return_statement identifier
Counts the number of times each element is used in a document
def find_bound_ports(self, ports): bound = [] for port in ports: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) try: s.bind((port.ip if port.ip is not NotSpecified else "127.0.0.1", port.host_port)) except socket.error as error: bound.append(port.host_port) finally: s.close() if bound: raise AlreadyBoundPorts(ports=bound)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier try_statement block expression_statement call attribute identifier identifier argument_list tuple conditional_expression attribute identifier identifier comparison_operator attribute identifier identifier identifier string string_start string_content string_end attribute identifier identifier except_clause as_pattern attribute identifier identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier finally_clause block expression_statement call attribute identifier identifier argument_list if_statement identifier block raise_statement call identifier argument_list keyword_argument identifier identifier
Find any ports that are already bound and complain about them
def preScale(self, sx, sy): self.a *= sx self.b *= sx self.c *= sy self.d *= sy return self
module function_definition identifier parameters identifier identifier identifier block expression_statement augmented_assignment attribute identifier identifier identifier expression_statement augmented_assignment attribute identifier identifier identifier expression_statement augmented_assignment attribute identifier identifier identifier expression_statement augmented_assignment attribute identifier identifier identifier return_statement identifier
Calculate pre scaling and replace current matrix.
def available_state_for_gene(self, gene: Gene, state: State) -> Tuple[State, ...]: result: List[State] = [] active_multiplex: Tuple[Multiplex] = gene.active_multiplex(state) transition: Transition = self.find_transition(gene, active_multiplex) current_state: int = state[gene] done = set() for target_state in transition.states: target_state: int = self._state_after_transition(current_state, target_state) if target_state not in done: done.add(target_state) new_state: State = state.copy() new_state[gene] = target_state result.append(new_state) return tuple(result)
module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_parameter identifier type identifier type generic_type identifier type_parameter type identifier type ellipsis block expression_statement assignment identifier type generic_type identifier type_parameter type identifier list expression_statement assignment identifier type generic_type identifier type_parameter type identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier type identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier type identifier subscript identifier identifier expression_statement assignment identifier call identifier argument_list for_statement identifier attribute identifier identifier block expression_statement assignment identifier type identifier call attribute identifier identifier argument_list identifier identifier if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier type identifier call attribute identifier identifier argument_list expression_statement assignment subscript identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement call identifier argument_list identifier
Return the state reachable from a given state for a particular gene.
def make_sh_address(script_string, witness=False, cashaddr=True): script_bytes = script_ser.serialize(script_string) return _ser_script_to_sh_address( script_bytes=script_bytes, witness=witness, cashaddr=cashaddr)
module function_definition identifier parameters identifier default_parameter identifier false default_parameter identifier true block expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
str, bool, bool -> str
def _at_exit(self): if self.process_exit: try: term = self.term if self.set_scroll: term.reset() else: term.move_to(0, term.height) self.term.feed() except ValueError: pass
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block try_statement block expression_statement assignment identifier attribute identifier identifier if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list else_clause block expression_statement call attribute identifier identifier argument_list integer attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list except_clause identifier block pass_statement
Resets terminal to normal configuration
def add_log_options(self, verbose_func=None, quiet_func=None): if not verbose_func: def verbose_func(): return log.config(verbose=True) if not quiet_func: def quiet_func(): return log.config(quiet=True) self.option('-v, --verbose', 'show more logs', verbose_func) self.option('-q, --quiet', 'show less logs', quiet_func) return self
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none block if_statement not_operator identifier block function_definition identifier parameters block return_statement call attribute identifier identifier argument_list keyword_argument identifier true if_statement not_operator identifier block function_definition identifier parameters block return_statement call attribute identifier identifier argument_list keyword_argument identifier true expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier return_statement identifier
A helper for setting up log options
def setup(interactive, not_relative, dry_run, reset, root_dir, testuser): click.echo("[cellpy] (setup)") init_filename = create_custom_init_filename() userdir, dst_file = get_user_dir_and_dst(init_filename) if testuser: if not root_dir: root_dir = os.getcwd() click.echo(f"[cellpy] (setup) DEV-MODE testuser: {testuser}") init_filename = create_custom_init_filename(testuser) userdir = root_dir dst_file = get_dst_file(userdir, init_filename) click.echo(f"[cellpy] (setup) DEV-MODE userdir: {userdir}") click.echo(f"[cellpy] (setup) DEV-MODE dst_file: {dst_file}") if not pathlib.Path(dst_file).is_file(): reset = True if interactive: click.echo(" interactive mode ".center(80, "-")) _update_paths(root_dir, not not_relative, dry_run=dry_run, reset=reset) _write_config_file( userdir, dst_file, init_filename, dry_run, ) _check() else: _write_config_file(userdir, dst_file, init_filename, dry_run) _check()
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier if_statement identifier block if_statement not_operator identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content interpolation identifier string_end expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content interpolation identifier string_end expression_statement call attribute identifier identifier argument_list string string_start string_content interpolation identifier string_end if_statement not_operator call attribute call attribute identifier identifier argument_list identifier identifier argument_list block expression_statement assignment identifier true if_statement identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list integer string string_start string_content string_end expression_statement call identifier argument_list identifier not_operator identifier keyword_argument identifier identifier keyword_argument identifier identifier expression_statement call identifier argument_list identifier identifier identifier identifier expression_statement call identifier argument_list else_clause block expression_statement call identifier argument_list identifier identifier identifier identifier expression_statement call identifier argument_list
This will help you to setup cellpy.
def download_file(url, path, session=None, params=None): if url[0:2] == '//': url = 'https://' + url[2:] tmp_path = path + '.tmp' if session and params: r = session.get( url, params=params, stream=True ) elif session and not params: r = session.get( url, stream=True ) else: r = requests.get(url, stream=True) with open(tmp_path, 'wb') as f: total_length = int(r.headers.get('content-length', 0)) for chunk in progress.bar(r.iter_content(chunk_size=1024), expected_size=(total_length / 1024) + 1): if chunk: f.write(chunk) f.flush() os.rename(tmp_path, path) return path
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none block if_statement comparison_operator subscript identifier slice integer integer string string_start string_content string_end block expression_statement assignment identifier binary_operator string string_start string_content string_end subscript identifier slice integer expression_statement assignment identifier binary_operator identifier string string_start string_content string_end if_statement boolean_operator identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier true elif_clause boolean_operator identifier not_operator identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier true else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier true with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement assignment identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end integer for_statement identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier integer keyword_argument identifier binary_operator parenthesized_expression binary_operator identifier integer integer block if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier identifier return_statement identifier
Download an individual file.
def getGenomeList() : import rabaDB.filters as rfilt f = rfilt.RabaQuery(Genome_Raba) names = [] for g in f.iterRun() : names.append(g.name) return names
module function_definition identifier parameters block import_statement aliased_import dotted_name 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 block expression_statement call attribute identifier identifier argument_list attribute identifier identifier return_statement identifier
Return the names of all imported genomes
def info(self): url = "{}/v7/finance/quote?symbols={}".format( self._base_url, self.ticker) r = _requests.get(url=url).json()["quoteResponse"]["result"] if len(r) > 0: return r[0] return {}
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement assignment identifier subscript subscript call attribute call attribute identifier identifier argument_list keyword_argument identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end if_statement comparison_operator call identifier argument_list identifier integer block return_statement subscript identifier integer return_statement dictionary
retreive metadata and currenct price data
def delete(self, key): obj = self._get_content() obj.pop(key, None) self.write_data(self.path, obj)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier none expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier
Removes the specified key from the database.
def _get(pseudodict, key, single=True): matches = [item[1] for item in pseudodict if item[0] == key] if single: return matches[0] else: return matches
module function_definition identifier parameters identifier identifier default_parameter identifier true block expression_statement assignment identifier list_comprehension subscript identifier integer for_in_clause identifier identifier if_clause comparison_operator subscript identifier integer identifier if_statement identifier block return_statement subscript identifier integer else_clause block return_statement identifier
Helper method for getting values from "multi-dict"s
def tick_clients(self): if not self._ticker: self._create_ticker() for client in self.clients.values(): self._ticker.tick(client)
module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block expression_statement call attribute 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
Trigger the periodic tick function in the client.
def _ascii_find_urls(bytes, mimetype, extra_tokens=True): tokens = _tokenize(bytes, mimetype, extra_tokens=extra_tokens) return tokens
module function_definition identifier parameters identifier identifier default_parameter identifier true block expression_statement assignment identifier call identifier argument_list identifier identifier keyword_argument identifier identifier return_statement identifier
This function finds URLs inside of ASCII bytes.
def open_in_browser(self, outfile): if self.browser == 'default': webbrowser.open('file://%s' % outfile) else: browser = webbrowser.get(self.browser) browser.open('file://%s' % outfile)
module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier
Open the given HTML file in a browser.
def updater(f): "Decorate a function with named arguments into updater for transact" @functools.wraps(f) def wrapped_updater(keys, values): result = f(*values) return (keys[:len(result)], result) return wrapped_updater
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end decorated_definition decorator call attribute identifier identifier argument_list identifier function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list list_splat identifier return_statement tuple subscript identifier slice call identifier argument_list identifier identifier return_statement identifier
Decorate a function with named arguments into updater for transact
def onlyOnce(fn): 'Set up FN to only run once within an interpreter instance' def wrap(*args, **kwargs): if hasattr(fn, 'called'): return fn.called = 1 return fn(*args, **kwargs) util.mergeFunctionMetadata(fn, wrap) return wrap
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 if_statement call identifier argument_list identifier string string_start string_content string_end block return_statement expression_statement assignment attribute identifier identifier integer return_statement call identifier argument_list list_splat identifier dictionary_splat identifier expression_statement call attribute identifier identifier argument_list identifier identifier return_statement identifier
Set up FN to only run once within an interpreter instance