code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def create_refund(self, refund_deets): request = self._post('transactions/refunds', refund_deets) return self.responder(request)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement call attribute identifier identifier argument_list identifier
Creates a new refund transaction.
def process_request(self, request, response): self.logger.info('Requested: {0} {1} {2}'.format(request.method, request.relative_uri, request.content_type))
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier
Logs the basic endpoint requested
def ListFlows(self): args = flow_pb2.ApiListFlowsArgs(client_id=self.client_id) items = self._context.SendIteratorRequest("ListFlows", args) return utils.MapItemsIterator( lambda data: flow.Flow(data=data, context=self._context), items)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier return_statement call attribute identifier identifier argument_list lambda lambda_parameters identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier identifier
List flows that ran on this client.
def encap(self, pkt): if pkt.name != Ether().name: raise TypeError('cannot encapsulate packet in MACsec, must be Ethernet') hdr = copy.deepcopy(pkt) payload = hdr.payload del hdr.payload tag = MACsec(sci=self.sci, an=self.an, SC=self.send_sci, E=self.e_bit(), C=self.c_bit(), shortlen=MACsecSA.shortlen(pkt), pn=(self.pn & 0xFFFFFFFF), type=pkt.type) hdr.type = ETH_P_MACSEC return hdr / tag / payload
module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier attribute call identifier argument_list identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier attribute identifier identifier delete_statement attribute identifier identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier call attribute identifier identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list identifier keyword_argument identifier parenthesized_expression binary_operator attribute identifier identifier integer keyword_argument identifier attribute identifier identifier expression_statement assignment attribute identifier identifier identifier return_statement binary_operator binary_operator identifier identifier identifier
encapsulate a frame using this Secure Association
def i(msg, *args, **kwargs): return logging.log(INFO, msg, *args, **kwargs)
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block return_statement call attribute identifier identifier argument_list identifier identifier list_splat identifier dictionary_splat identifier
log a message at info level;
def kick(self, channel, target, reason=None): if reason: target += ' :' + reason self.send_line('KICK %s %s' % (channel, target), nowait=True)
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none block if_statement identifier block expression_statement augmented_assignment identifier binary_operator string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier keyword_argument identifier true
kick target from channel
def go_to_next_cell(self): cursor = self.textCursor() cursor.movePosition(QTextCursor.NextBlock) cur_pos = prev_pos = cursor.position() while not self.is_cell_separator(cursor): cursor.movePosition(QTextCursor.NextBlock) prev_pos = cur_pos cur_pos = cursor.position() if cur_pos == prev_pos: return self.setTextCursor(cursor)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier assignment identifier call attribute identifier identifier argument_list while_statement not_operator call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier identifier block return_statement expression_statement call attribute identifier identifier argument_list identifier
Go to the next cell of lines
def _create(self, cache_file): conn = sqlite3.connect(cache_file) cur = conn.cursor() cur.execute("PRAGMA foreign_keys = ON") cur.execute( ) cur.execute( ) conn.commit() conn.close()
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list
Create the tables needed to store the information.
def _anova(self, dv=None, between=None, detailed=False, export_filename=None): aov = anova(data=self, dv=dv, between=between, detailed=detailed, export_filename=export_filename) return aov
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier false default_parameter identifier none block expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier return_statement identifier
Return one-way and two-way ANOVA.
def OnCardRightClick(self, event): item = event.GetItem() if item: itemdata = self.readertreepanel.cardtreectrl.GetItemPyData(item) if isinstance(itemdata, smartcard.Card.Card): self.selectedcard = itemdata if not hasattr(self, "connectID"): self.connectID = wx.NewId() self.disconnectID = wx.NewId() self.Bind(wx.EVT_MENU, self.OnConnect, id=self.connectID) self.Bind( wx.EVT_MENU, self.OnDisconnect, id=self.disconnectID) menu = wx.Menu() if not hasattr(self.selectedcard, 'connection'): menu.Append(self.connectID, "Connect") else: menu.Append(self.disconnectID, "Disconnect") self.PopupMenu(menu) menu.Destroy()
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement identifier block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list identifier if_statement call identifier argument_list identifier attribute attribute identifier identifier identifier block expression_statement assignment attribute identifier identifier identifier if_statement not_operator call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list if_statement not_operator call identifier argument_list attribute identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list attribute identifier identifier string string_start string_content string_end else_clause block expression_statement call attribute identifier identifier argument_list attribute identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list
Called when user right-clicks a node in the card tree control.
def parser(cls, v): return geoid.census.State.parse(str(v).zfill(2))
module function_definition identifier parameters identifier identifier block return_statement call attribute attribute attribute identifier identifier identifier identifier argument_list call attribute call identifier argument_list identifier identifier argument_list integer
Ensure that the upstream parser gets two digits.
def debug(level=logging.DEBUG): from jcvi.apps.console import magenta, yellow format = yellow("%(asctime)s [%(module)s]") format += magenta(" %(message)s") logging.basicConfig(level=level, format=format, datefmt="%H:%M:%S")
module function_definition identifier parameters default_parameter identifier attribute identifier identifier block import_from_statement dotted_name identifier identifier identifier dotted_name identifier dotted_name identifier expression_statement assignment identifier call identifier argument_list string string_start string_content string_end expression_statement augmented_assignment identifier call identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end
Turn on the debugging
def index(self, child_pid): if not isinstance(child_pid, PersistentIdentifier): child_pid = resolve_pid(child_pid) relation = PIDRelation.query.filter_by( parent=self._resolved_pid, child=child_pid, relation_type=self.relation_type.id).one() return relation.index
module function_definition identifier parameters identifier identifier block if_statement not_operator call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute attribute identifier identifier identifier identifier argument_list return_statement attribute identifier identifier
Index of the child in the relation.
def _get_module(self, line): for sline in self._source: if len(sline) > 0 and sline[0] != "!": rmatch = self.RE_MODULE.match(sline) if rmatch is not None: self.modulename = rmatch.group("name") break else: return self.parser.isense_parse(self._orig_path, self.modulename) self.module = self.parser.modules[self.modulename] if line > self.module.contains_index: self.section = "contains"
module function_definition identifier parameters identifier identifier block for_statement identifier attribute identifier identifier block if_statement boolean_operator comparison_operator call identifier argument_list identifier integer comparison_operator subscript identifier integer string string_start string_content string_end block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end break_statement else_clause block return_statement expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier subscript attribute attribute identifier identifier identifier attribute identifier identifier if_statement comparison_operator identifier attribute attribute identifier identifier identifier block expression_statement assignment attribute identifier identifier string string_start string_content string_end
Finds the name of the module and retrieves it from the parser cache.
def show_scan_report(audio_filepaths, album_dir, r128_data): for audio_filepath in audio_filepaths: try: loudness, peak = r128_data[audio_filepath] except KeyError: loudness, peak = "SKIPPED", "SKIPPED" else: loudness = "%.1f LUFS" % (loudness) if peak is None: peak = "-" else: peak = "%.1f dBFS" % (scale_to_gain(peak)) logger().info("File '%s': loudness = %s, sample peak = %s" % (audio_filepath, loudness, peak)) if album_dir: try: album_loudness, album_peak = r128_data[ALBUM_GAIN_KEY] except KeyError: album_loudness, album_peak = "SKIPPED", "SKIPPED" else: album_loudness = "%.1f LUFS" % (album_loudness) if album_peak is None: album_peak = "-" else: album_peak = "%.1f dBFS" % (scale_to_gain(album_peak)) logger().info("Album '%s': loudness = %s, sample peak = %s" % (album_dir, album_loudness, album_peak))
module function_definition identifier parameters identifier identifier identifier block for_statement identifier identifier block try_statement block expression_statement assignment pattern_list identifier identifier subscript identifier identifier except_clause identifier block expression_statement assignment pattern_list identifier identifier expression_list string string_start string_content string_end string string_start string_content string_end else_clause block expression_statement assignment identifier binary_operator string string_start string_content string_end parenthesized_expression identifier if_statement comparison_operator identifier none block expression_statement assignment identifier string string_start string_content string_end else_clause block expression_statement assignment identifier binary_operator string string_start string_content string_end parenthesized_expression call identifier argument_list identifier expression_statement call attribute call identifier argument_list identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier identifier if_statement identifier block try_statement block expression_statement assignment pattern_list identifier identifier subscript identifier identifier except_clause identifier block expression_statement assignment pattern_list identifier identifier expression_list string string_start string_content string_end string string_start string_content string_end else_clause block expression_statement assignment identifier binary_operator string string_start string_content string_end parenthesized_expression identifier if_statement comparison_operator identifier none block expression_statement assignment identifier string string_start string_content string_end else_clause block expression_statement assignment identifier binary_operator string string_start string_content string_end parenthesized_expression call identifier argument_list identifier expression_statement call attribute call identifier argument_list identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier identifier
Display loudness scan results.
def register_halfmaxes(self, telescope, band, lower, upper): if (telescope, band) in self._halfmaxes: raise AlreadyDefinedError('half-max points for %s/%s already ' 'defined', telescope, band) self._note(telescope, band) self._halfmaxes[telescope,band] = (lower, upper) return self
module function_definition identifier parameters identifier identifier identifier identifier identifier block if_statement comparison_operator tuple identifier identifier attribute identifier identifier block raise_statement call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement assignment subscript attribute identifier identifier identifier identifier tuple identifier identifier return_statement identifier
Register precomputed half-max points.
def discard_incoming_messages(self): self.inbox.clear() previous = self._discard_incoming_messages self._discard_incoming_messages = True try: yield finally: self._discard_incoming_messages = previous
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier attribute identifier identifier expression_statement assignment attribute identifier identifier true try_statement block expression_statement yield finally_clause block expression_statement assignment attribute identifier identifier identifier
Discard all incoming messages for the time of the context manager.
def create_distant_reference(self, ref_data): self.validate_reference_data(ref_data) creation_status = self._zotero_lib.create_items([ref_data]) try: created_item = creation_status["successful"]["0"] return created_item except KeyError as e: print(creation_status) raise CreateZoteroItemError from e
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list list identifier try_statement block expression_statement assignment identifier subscript subscript identifier string string_start string_content string_end string string_start string_content string_end return_statement identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call identifier argument_list identifier raise_statement identifier identifier
Validate and create the reference in Zotero and return the created item.
def from_bs_date(cls, year, month, day): return NepDate(year, month, day).update()
module function_definition identifier parameters identifier identifier identifier identifier block return_statement call attribute call identifier argument_list identifier identifier identifier identifier argument_list
Create and update an NepDate object for bikram sambat date
def parse(self): errors_tested = 0 for error in self.error_definitions: errors_tested += 1 result = self.parse_single(self.error_definitions[error]) if result[0]: self.errors.append(error(result[1], result[2])) if len(self.errors) > 0: print('QUEUE_ERROR FOUND') for error in self.errors: print(error) return errors_tested
module function_definition identifier parameters identifier block expression_statement assignment identifier integer for_statement identifier attribute identifier identifier block expression_statement augmented_assignment identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list subscript attribute identifier identifier identifier if_statement subscript identifier integer block expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list subscript identifier integer subscript identifier integer if_statement comparison_operator call identifier argument_list attribute identifier identifier integer block expression_statement call identifier argument_list string string_start string_content string_end for_statement identifier attribute identifier identifier block expression_statement call identifier argument_list identifier return_statement identifier
Parse for the occurens of all errors defined in ERRORS
def getData(file_id,ra,dec): DATA="www.cadc-ccda.hia-iha.nrc-cnrc.gc.ca" BASE="http://"+DATA+"/authProxy/getData" archive="CFHT" wcs="corrected" import re groups=re.match('^(?P<file_id>\d{6}).*',file_id) if not groups: return None file_id=groups.group('file_id') file_id+="p" URL=BASE+"?dataset_name="+file_id+"&cutout=circle("+str(ra*57.3)+"," URL+=str(dec*57.3)+","+str(5.0/60.0)+")" return URL
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier binary_operator binary_operator string string_start string_content string_end identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end import_statement dotted_name identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement not_operator identifier block return_statement none expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement augmented_assignment identifier string string_start string_content string_end expression_statement assignment identifier binary_operator binary_operator binary_operator binary_operator binary_operator identifier string string_start string_content string_end identifier string string_start string_content string_end call identifier argument_list binary_operator identifier float string string_start string_content string_end expression_statement augmented_assignment identifier binary_operator binary_operator binary_operator call identifier argument_list binary_operator identifier float string string_start string_content string_end call identifier argument_list binary_operator float float string string_start string_content string_end return_statement identifier
Create a link that connects to a getData URL
def copy_file(self, infile, outfile, check=True): self.ensure_dir(os.path.dirname(outfile)) logger.info('Copying %s to %s', infile, outfile) if not self.dry_run: msg = None if check: if os.path.islink(outfile): msg = '%s is a symlink' % outfile elif os.path.exists(outfile) and not os.path.isfile(outfile): msg = '%s is a non-regular file' % outfile if msg: raise ValueError(msg + ' which would be overwritten') shutil.copyfile(infile, outfile) self.record_as_written(outfile)
module function_definition identifier parameters identifier identifier identifier default_parameter identifier true block expression_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier if_statement not_operator attribute identifier identifier block expression_statement assignment identifier none if_statement identifier block if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end identifier elif_clause boolean_operator call attribute attribute identifier identifier identifier argument_list identifier not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end identifier if_statement identifier block raise_statement call identifier argument_list binary_operator identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list identifier
Copy a file respecting dry-run and force flags.
def _get_directory_path(context): path = os.path.join(settings.BASE_PATH, 'store') path = context.params.get('path', path) path = os.path.join(path, context.crawler.name) path = os.path.abspath(os.path.expandvars(path)) try: os.makedirs(path) except Exception: pass return path
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier try_statement block expression_statement call attribute identifier identifier argument_list identifier except_clause identifier block pass_statement return_statement identifier
Get the storage path fro the output.
def convert(self, argument): if _is_integer_type(argument): return argument elif isinstance(argument, six.string_types): base = 10 if len(argument) > 2 and argument[0] == '0': if argument[1] == 'o': base = 8 elif argument[1] == 'x': base = 16 return int(argument, base) else: raise TypeError('Expect argument to be a string or int, found {}'.format( type(argument)))
module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier block return_statement identifier elif_clause call identifier argument_list identifier attribute identifier identifier block expression_statement assignment identifier integer if_statement boolean_operator comparison_operator call identifier argument_list identifier integer comparison_operator subscript identifier integer string string_start string_content string_end block if_statement comparison_operator subscript identifier integer string string_start string_content string_end block expression_statement assignment identifier integer elif_clause comparison_operator subscript identifier integer string string_start string_content string_end block expression_statement assignment identifier integer return_statement call identifier argument_list identifier identifier else_clause block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier
Returns the int value of argument.
def sparse_arrays(self, value): if not isinstance(value, bool): raise TypeError('sparse_arrays attribute must be a logical type.') self._sparse_arrays = value
module function_definition identifier parameters identifier identifier block if_statement not_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier identifier
Validate and enable spare arrays.
def make_event_data(self, flavor, data): if not flavor.startswith('_'): raise ValueError('Event flavor must start with _underscore') d = {'source': {'space': self._event_space, 'id': self._source_id}} d.update(data) return {flavor: d}
module function_definition identifier parameters identifier identifier identifier block if_statement not_operator call attribute identifier identifier argument_list string string_start string_content string_end block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier dictionary pair string string_start string_content string_end dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement dictionary pair identifier identifier
Marshall ``flavor`` and ``data`` into a standard event.
def _apply_uncertainty_to_geometry(self, source, value): if self.uncertainty_type == 'simpleFaultDipRelative': source.modify('adjust_dip', dict(increment=value)) elif self.uncertainty_type == 'simpleFaultDipAbsolute': source.modify('set_dip', dict(dip=value)) elif self.uncertainty_type == 'simpleFaultGeometryAbsolute': trace, usd, lsd, dip, spacing = value source.modify( 'set_geometry', dict(fault_trace=trace, upper_seismogenic_depth=usd, lower_seismogenic_depth=lsd, dip=dip, spacing=spacing)) elif self.uncertainty_type == 'complexFaultGeometryAbsolute': edges, spacing = value source.modify('set_geometry', dict(edges=edges, spacing=spacing)) elif self.uncertainty_type == 'characteristicFaultGeometryAbsolute': source.modify('set_geometry', dict(surface=value))
module function_definition identifier parameters identifier 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 string string_start string_content string_end call identifier argument_list keyword_argument identifier identifier elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list keyword_argument identifier identifier elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment pattern_list identifier identifier identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment pattern_list identifier identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list keyword_argument identifier identifier
Modify ``source`` geometry with the uncertainty value ``value``
def instance_provisioned(device_id): session = db.get_reader_session() with session.begin(): port_model = models_v2.Port res = bool(session.query(port_model) .filter(port_model.device_id == device_id).count()) return res
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list with_statement with_clause with_item call attribute identifier identifier argument_list block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list call attribute call attribute call attribute identifier identifier argument_list identifier identifier argument_list comparison_operator attribute identifier identifier identifier identifier argument_list return_statement identifier
Returns true if any ports exist for an instance.
def validate(key, val): if val and val.startswith("~/"): return os.path.expanduser(val) if key == "output_header_frequency": return int(val, 10) if key.endswith("_ecma48"): return eval("'%s'" % val.replace("'", r"\'")) return val
module function_definition identifier parameters identifier identifier block if_statement boolean_operator identifier call attribute identifier identifier argument_list string string_start string_content string_end block return_statement call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator identifier string string_start string_content string_end block return_statement call identifier argument_list identifier integer if_statement call attribute identifier identifier argument_list string string_start string_content string_end block return_statement call identifier argument_list binary_operator string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end return_statement identifier
Validate a configuration value.
def setOverlayInputMethod(self, ulOverlayHandle, eInputMethod): fn = self.function_table.setOverlayInputMethod result = fn(ulOverlayHandle, eInputMethod) return result
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier return_statement identifier
Sets the input settings for the specified overlay.
def syncParamList(self, firstTime, preserve_order=True): new_list = self._getParamsFromConfigDict(self, initialPass=firstTime) if self._forUseWithEpar: new_list.append(basicpar.IrafParS(['$nargs','s','h','N'])) if len(self.__paramList) > 0 and preserve_order: namesInOrder = [p.fullName() for p in self.__paramList] assert len(namesInOrder) == len(new_list), \ 'Mismatch in num pars, had: '+str(len(namesInOrder))+ \ ', now we have: '+str(len(new_list))+', '+ \ str([p.fullName() for p in new_list]) self.__paramList[:] = [] new_list_dict = {} for par in new_list: new_list_dict[par.fullName()] = par for fn in namesInOrder: self.__paramList.append(new_list_dict[fn]) else: self.__paramList[:] = new_list
module function_definition identifier parameters identifier identifier default_parameter identifier true block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list 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 if_statement boolean_operator comparison_operator call identifier argument_list attribute identifier identifier integer identifier block expression_statement assignment identifier list_comprehension call attribute identifier identifier argument_list for_in_clause identifier attribute identifier identifier assert_statement comparison_operator call identifier argument_list identifier call identifier argument_list identifier binary_operator binary_operator binary_operator binary_operator binary_operator string string_start string_content string_end call identifier argument_list call identifier argument_list identifier string string_start string_content string_end call identifier argument_list call identifier argument_list identifier string string_start string_content string_end line_continuation call identifier argument_list list_comprehension call attribute identifier identifier argument_list for_in_clause identifier identifier expression_statement assignment subscript attribute identifier identifier slice list expression_statement assignment identifier dictionary for_statement identifier identifier block expression_statement assignment subscript identifier call attribute identifier identifier argument_list identifier for_statement identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list subscript identifier identifier else_clause block expression_statement assignment subscript attribute identifier identifier slice identifier
Set or reset the internal param list from the dict's contents.
def turn_left(): motors.left_motor(150) motors.right_motor(150) board.sleep(0.5) motors.brake(); board.sleep(0.1)
module function_definition identifier parameters block expression_statement call attribute identifier identifier argument_list integer expression_statement call attribute identifier identifier argument_list integer expression_statement call attribute identifier identifier argument_list float expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list float
turns RedBot to the Left
def make_subgraph(graph, vertices, edges): local_graph = copy.deepcopy(graph) edges_to_delete = [x for x in local_graph.get_all_edge_ids() if x not in edges] for e in edges_to_delete: local_graph.delete_edge_by_id(e) nodes_to_delete = [x for x in local_graph.get_all_node_ids() if x not in vertices] for n in nodes_to_delete: local_graph.delete_node(n) return local_graph
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier list_comprehension identifier for_in_clause identifier call attribute identifier identifier argument_list if_clause comparison_operator identifier identifier for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier list_comprehension identifier for_in_clause identifier call attribute identifier identifier argument_list if_clause comparison_operator identifier identifier for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Converts a subgraph given by a list of vertices and edges into a graph object.
def _get_hanging_wall_term(self, C, rup, dists): return (C["c10"] * self._get_hanging_wall_coeffs_rx(C, rup, dists.rx) * self._get_hanging_wall_coeffs_rrup(dists) * self._get_hanging_wall_coeffs_mag(C, rup.mag) * self._get_hanging_wall_coeffs_ztor(rup.ztor) * self._get_hanging_wall_coeffs_dip(rup.dip))
module function_definition identifier parameters identifier identifier identifier identifier block return_statement parenthesized_expression binary_operator binary_operator binary_operator binary_operator binary_operator subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list identifier identifier attribute identifier identifier call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier
Returns the hanging wall scaling term defined in equations 7 to 16
def trim(self): now_time = time.time() while self._seq and self._seq[0].expire_time < now_time: item = self._seq.popleft() del self._map[item.key] if self._max_items: while self._seq and len(self._seq) > self._max_items: item = self._seq.popleft() del self._map[item.key]
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list while_statement boolean_operator attribute identifier identifier comparison_operator attribute subscript attribute identifier identifier integer identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list delete_statement subscript attribute identifier identifier attribute identifier identifier if_statement attribute identifier identifier block while_statement boolean_operator attribute identifier identifier comparison_operator call identifier argument_list attribute identifier identifier attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list delete_statement subscript attribute identifier identifier attribute identifier identifier
Remove items that are expired or exceed the max size.
def visit_name(self, node, parent): context = self._get_context(node) if context == astroid.Del: newnode = nodes.DelName(node.id, node.lineno, node.col_offset, parent) elif context == astroid.Store: newnode = nodes.AssignName(node.id, node.lineno, node.col_offset, parent) elif node.id in CONST_NAME_TRANSFORMS: newnode = nodes.Const( CONST_NAME_TRANSFORMS[node.id], getattr(node, "lineno", None), getattr(node, "col_offset", None), parent, ) return newnode else: newnode = nodes.Name(node.id, node.lineno, node.col_offset, parent) if context in (astroid.Del, astroid.Store): self._save_assignment(newnode) return newnode
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier identifier elif_clause comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier identifier elif_clause comparison_operator attribute identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier attribute identifier identifier call identifier argument_list identifier string string_start string_content string_end none call identifier argument_list identifier string string_start string_content string_end none identifier return_statement identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier identifier if_statement comparison_operator identifier tuple attribute identifier identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
visit a Name node by returning a fresh instance of it
def install(self): packages = self.packages() if packages: print("") for pkg in packages: ver = SBoGrep(pkg).version() prgnam = "{0}-{1}".format(pkg, ver) if find_package(prgnam, self.meta.output): binary = slack_package(prgnam) PackageManager(binary).upgrade(flag="--install-new") else: print("\nPackage {0} not found in the {1} for " "installation\n".format(prgnam, self.meta.output)) else: print("\nPackages not found in the queue for installation\n") raise SystemExit(1)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement identifier block expression_statement call identifier argument_list string string_start string_end for_statement identifier identifier block expression_statement assignment identifier call attribute call identifier argument_list identifier identifier argument_list expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier identifier if_statement call identifier argument_list identifier attribute attribute identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute call identifier argument_list identifier identifier argument_list keyword_argument identifier string string_start string_content string_end else_clause block expression_statement call identifier argument_list call attribute concatenated_string string string_start string_content escape_sequence string_end string string_start string_content escape_sequence string_end identifier argument_list identifier attribute attribute identifier identifier identifier else_clause block expression_statement call identifier argument_list string string_start string_content escape_sequence escape_sequence string_end raise_statement call identifier argument_list integer
Install packages from queue
def custom_popen(cmd): creationflags = 0 if sys.platform == 'win32': creationflags = 0x08000000 try: p = Popen(cmd, bufsize=0, stdout=PIPE, stdin=PIPE, stderr=STDOUT, creationflags=creationflags) except OSError as ex: if ex.errno == errno.ENOENT: raise RarCannotExec("Unrar not installed? (rarfile.UNRAR_TOOL=%r)" % UNRAR_TOOL) if ex.errno == errno.EACCES or ex.errno == errno.EPERM: raise RarCannotExec("Cannot execute unrar (rarfile.UNRAR_TOOL=%r)" % UNRAR_TOOL) raise return p
module function_definition identifier parameters identifier block expression_statement assignment identifier integer if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier integer try_statement block expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier integer keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier except_clause as_pattern identifier as_pattern_target identifier block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier if_statement boolean_operator comparison_operator attribute identifier identifier attribute identifier identifier comparison_operator attribute identifier identifier attribute identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier raise_statement return_statement identifier
Disconnect cmd from parent fds, read only from stdout.
def create_user_profile(sender, instance, created, **kwargs): if created: profile = UserProfile.objects.get_or_create(user=instance)[0] profile.hash_pass = create_htpasswd(instance.hash_pass) profile.save() else: try: up = UserProfile.objects.get(user=instance.id) up.hash_pass = create_htpasswd(instance.hash_pass) up.save() except AttributeError: pass
module function_definition identifier parameters identifier identifier identifier dictionary_splat_pattern identifier block if_statement identifier block expression_statement assignment identifier subscript call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier integer expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list else_clause block try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list except_clause identifier block pass_statement
Create the UserProfile when a new User is saved
def list_wallet_names(api_key, is_hd_wallet=False, coin_symbol='btc'): assert is_valid_coin_symbol(coin_symbol), coin_symbol assert api_key params = {'token': api_key} kwargs = dict(wallets='hd' if is_hd_wallet else '') url = make_url(coin_symbol, **kwargs) r = requests.get(url, params=params, verify=True, timeout=TIMEOUT_IN_SECONDS) return get_valid_json(r)
module function_definition identifier parameters identifier default_parameter identifier false default_parameter identifier string string_start string_content string_end block assert_statement call identifier argument_list identifier identifier assert_statement identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier conditional_expression string string_start string_content string_end identifier string string_start string_end expression_statement assignment identifier call identifier argument_list identifier dictionary_splat identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier true keyword_argument identifier identifier return_statement call identifier argument_list identifier
Get all the wallets belonging to an API key
def combine_xml_points(l, units, handle_units): ret = {} for item in l: for key, value in item.items(): ret.setdefault(key, []).append(value) for key, value in ret.items(): if key != 'date': ret[key] = handle_units(value, units.get(key, None)) return ret
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier dictionary for_statement identifier identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement call attribute call attribute identifier identifier argument_list identifier list identifier argument_list identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment subscript identifier identifier call identifier argument_list identifier call attribute identifier identifier argument_list identifier none return_statement identifier
Combine multiple Point tags into an array.
def date_to_um_date(date): assert date.hour == 0 and date.minute == 0 and date.second == 0 return [date.year, date.month, date.day, 0, 0, 0]
module function_definition identifier parameters identifier block assert_statement boolean_operator boolean_operator comparison_operator attribute identifier identifier integer comparison_operator attribute identifier identifier integer comparison_operator attribute identifier identifier integer return_statement list attribute identifier identifier attribute identifier identifier attribute identifier identifier integer integer integer
Convert a date object to 'year, month, day, hour, minute, second.'
def analyze(self, scratch, **kwargs): changes = dict((x.name, self.sprite_changes(x)) for x in scratch.sprites) changes['stage'] = { 'background': self.attribute_state(scratch.stage.scripts, 'costume')} return {'initialized': changes}
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier generator_expression tuple attribute identifier identifier call attribute identifier identifier argument_list identifier for_in_clause identifier attribute identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end dictionary pair string string_start string_content string_end call attribute identifier identifier argument_list attribute attribute identifier identifier identifier string string_start string_content string_end return_statement dictionary pair string string_start string_content string_end identifier
Run and return the results of the AttributeInitialization plugin.
def serialize_dict(self, msg_dict): serialized = json.dumps(msg_dict, namedtuple_as_object=False) if PY2: serialized = serialized.decode("utf-8") serialized = "{}\nend\n".format(serialized) return serialized
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier false if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute string string_start string_content escape_sequence escape_sequence string_end identifier argument_list identifier return_statement identifier
Serialize to JSON a message dictionary.
def _badlink(info, base): tip = _resolved(os.path.join(base, os.path.dirname(info.name))) return _badpath(info.linkname, base=tip)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier return_statement call identifier argument_list attribute identifier identifier keyword_argument identifier identifier
Links are interpreted relative to the directory containing the link
def new_from_memory(cls, data): size = len(data) copy = g_memdup(data, size) ptr = cast(copy, POINTER(guint8)) try: with gerror(GIError) as error: return GITypelib._new_from_memory(ptr, size, error) except GIError: free(copy) raise
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list identifier call identifier argument_list identifier try_statement block with_statement with_clause with_item as_pattern call identifier argument_list identifier as_pattern_target identifier block return_statement call attribute identifier identifier argument_list identifier identifier identifier except_clause identifier block expression_statement call identifier argument_list identifier raise_statement
Takes bytes and returns a GITypelib, or raises GIError
def engine_data(engine): views = ("default", "main", "started", "stopped", "complete", "incomplete", "seeding", "leeching", "active", "messages") methods = [ "throttle.global_up.rate", "throttle.global_up.max_rate", "throttle.global_down.rate", "throttle.global_down.max_rate", ] proxy = engine.open() calls = [dict(methodName=method, params=[]) for method in methods] \ + [dict(methodName="view.size", params=['', view]) for view in views] result = proxy.system.multicall(calls, flatten=True) data = dict( now = time.time(), engine_id = engine.engine_id, versions = engine.versions, uptime = engine.uptime, upload = [result[0], result[1]], download = [result[2], result[3]], views = dict([(name, result[4+i]) for i, name in enumerate(views) ]), ) return data
module function_definition identifier parameters identifier block expression_statement assignment identifier tuple string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end 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 assignment identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier binary_operator list_comprehension call identifier argument_list keyword_argument identifier identifier keyword_argument identifier list for_in_clause identifier identifier line_continuation list_comprehension call identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier list string string_start string_end identifier for_in_clause identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier true expression_statement assignment identifier call identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier list subscript identifier integer subscript identifier integer keyword_argument identifier list subscript identifier integer subscript identifier integer keyword_argument identifier call identifier argument_list list_comprehension tuple identifier subscript identifier binary_operator integer identifier for_in_clause pattern_list identifier identifier call identifier argument_list identifier return_statement identifier
Get important performance data and metadata from rTorrent.
def random_population(dna_size, pop_size, tune_params): population = [] for _ in range(pop_size): dna = [] for i in range(dna_size): dna.append(random_val(i, tune_params)) population.append(dna) return population
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier list for_statement identifier call identifier argument_list identifier block expression_statement assignment identifier list for_statement identifier call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
create a random population
def force_invalidate(self, cache_key): try: if self.cacheable(cache_key): os.unlink(self._sha_file(cache_key)) except OSError as e: if e.errno != errno.ENOENT: raise
module function_definition identifier parameters identifier identifier block try_statement block if_statement call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block raise_statement
Force-invalidate the cached item.
def properties_changed(self, sender, changed_properties, invalidated_properties): if 'Connected' in changed_properties: if changed_properties['Connected']: self.connect_succeeded() else: self.disconnect_succeeded() if ('ServicesResolved' in changed_properties and changed_properties['ServicesResolved'] == 1 and not self.services): self.services_resolved()
module function_definition identifier parameters identifier identifier identifier identifier block if_statement comparison_operator string string_start string_content string_end identifier block if_statement subscript identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list else_clause block expression_statement call attribute identifier identifier argument_list if_statement parenthesized_expression boolean_operator boolean_operator comparison_operator string string_start string_content string_end identifier comparison_operator subscript identifier string string_start string_content string_end integer not_operator attribute identifier identifier block expression_statement call attribute identifier identifier argument_list
Called when a device property has changed or got invalidated.
def background_reader(stream, loop: asyncio.AbstractEventLoop, callback): for line in iter(stream.readline, b''): loop.call_soon_threadsafe(loop.create_task, callback(line))
module function_definition identifier parameters identifier typed_parameter identifier type attribute identifier identifier identifier block for_statement identifier call identifier argument_list attribute identifier identifier string string_start string_end block expression_statement call attribute identifier identifier argument_list attribute identifier identifier call identifier argument_list identifier
Reads a stream and forwards each line to an async callback.
def include_block(self, x): last_pos = self._chr_last_blocks.get(x.chrom, 0) if last_pos <= self._end_buffer and x.stop >= self._ref_sizes.get(x.chrom, 0) - self._end_buffer: return True elif self._ref_sizes.get(x.chrom, 0) <= self._target_size: return False elif (x.start - last_pos) > self._target_size: self._chr_last_blocks[x.chrom] = x.stop return True else: return False
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier integer if_statement boolean_operator comparison_operator identifier attribute identifier identifier comparison_operator attribute identifier identifier binary_operator call attribute attribute identifier identifier identifier argument_list attribute identifier identifier integer attribute identifier identifier block return_statement true elif_clause comparison_operator call attribute attribute identifier identifier identifier argument_list attribute identifier identifier integer attribute identifier identifier block return_statement false elif_clause comparison_operator parenthesized_expression binary_operator attribute identifier identifier identifier attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier attribute identifier identifier attribute identifier identifier return_statement true else_clause block return_statement false
Check for inclusion of block based on distance from previous.
def dispatch(self, request, *args, **kwargs): self.request = request self.args = args self.kwargs = kwargs response = self.check_permissions(request) if response: return response return super().dispatch(request, *args, **kwargs)
module function_definition identifier parameters identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement identifier block return_statement identifier return_statement call attribute call identifier argument_list identifier argument_list identifier list_splat identifier dictionary_splat identifier
Dispatches an incoming request.
def subsystem_dependencies_iter(cls): for dep in cls.subsystem_dependencies(): if isinstance(dep, SubsystemDependency): yield dep else: yield SubsystemDependency(dep, GLOBAL_SCOPE, removal_version=None, removal_hint=None)
module function_definition identifier parameters identifier block for_statement identifier call attribute identifier identifier argument_list block if_statement call identifier argument_list identifier identifier block expression_statement yield identifier else_clause block expression_statement yield call identifier argument_list identifier identifier keyword_argument identifier none keyword_argument identifier none
Iterate over the direct subsystem dependencies of this Optionable.
def import_spydercustomize(): here = osp.dirname(__file__) parent = osp.dirname(here) customize_dir = osp.join(parent, 'customize') while '' in sys.path: sys.path.remove('') site.addsitedir(customize_dir) import spydercustomize try: sys.path.remove(customize_dir) except ValueError: pass
module function_definition identifier parameters block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end while_statement comparison_operator string string_start string_end attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_end expression_statement call attribute identifier identifier argument_list identifier import_statement dotted_name identifier try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list identifier except_clause identifier block pass_statement
Import our customizations into the kernel.
def _generate_throw_error(self, name, reason): throw_exc = '@throw([NSException exceptionWithName:@"{}" reason:{} userInfo:nil]);' self.emit(throw_exc.format(name, reason))
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier identifier
Emits a generic error throwing line.
def create_product(name, abbreviation, **kwargs): data = create_product_raw(name, abbreviation, **kwargs) if data: return utils.format_json(data)
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list identifier identifier dictionary_splat identifier if_statement identifier block return_statement call attribute identifier identifier argument_list identifier
Create a new Product
def _convertNonZeroToFailure(self, res): "utility method to handle the result of getProcessOutputAndValue" (stdout, stderr, code) = res if code != 0: raise EnvironmentError( 'command failed with exit code %d: %s' % (code, stderr)) return (stdout, stderr, code)
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end expression_statement assignment tuple_pattern identifier identifier identifier identifier if_statement comparison_operator identifier integer block raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier return_statement tuple identifier identifier identifier
utility method to handle the result of getProcessOutputAndValue
def add_permalink_methods(content_inst): for permalink_method in PERMALINK_METHODS: setattr( content_inst, permalink_method.__name__, permalink_method.__get__(content_inst, content_inst.__class__))
module function_definition identifier parameters identifier block for_statement identifier identifier block expression_statement call identifier argument_list identifier attribute identifier identifier call attribute identifier identifier argument_list identifier attribute identifier identifier
Add permalink methods to object
def amended_commits(commits): amended_sha1s = [] for message in commits.values(): amended_sha1s.extend(re.findall(r'AMENDS\s([0-f]+)', message)) return amended_sha1s
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement identifier
Return those git commit sha1s that have been amended later.
def drunk_value(grid): "Return the expected value to the player if both players play at random." if is_won(grid): return -1 succs = successors(grid) return -average(map(drunk_value, succs)) if succs else 0
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end if_statement call identifier argument_list identifier block return_statement unary_operator integer expression_statement assignment identifier call identifier argument_list identifier return_statement conditional_expression unary_operator call identifier argument_list call identifier argument_list identifier identifier identifier integer
Return the expected value to the player if both players play at random.
def _init_dbus(self): _bus = SessionBus() if self.device_id is None: self.device_id = self._get_device_id(_bus) if self.device_id is None: return False try: self._dev = _bus.get(SERVICE_BUS, DEVICE_PATH + "/%s" % self.device_id) except Exception: return False return True
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator attribute identifier identifier none block return_statement false try_statement block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier binary_operator identifier binary_operator string string_start string_content string_end attribute identifier identifier except_clause identifier block return_statement false return_statement true
Get the device id
def privateparts(self, domain): s = self.privatesuffix(domain) if s is None: return None else: pre = domain[0:-(len(s)+1)] if pre == "": return (s,) else: return tuple(pre.split(".") + [s])
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block return_statement none else_clause block expression_statement assignment identifier subscript identifier slice integer unary_operator parenthesized_expression binary_operator call identifier argument_list identifier integer if_statement comparison_operator identifier string string_start string_end block return_statement tuple identifier else_clause block return_statement call identifier argument_list binary_operator call attribute identifier identifier argument_list string string_start string_content string_end list identifier
Return tuple of labels and the private suffix.
def _process_token(cls, token): assert type(token) is _TokenType or callable(token), \ 'token type must be simple type or callable, not %r' % (token,) return token
module function_definition identifier parameters identifier identifier block assert_statement boolean_operator comparison_operator call identifier argument_list identifier identifier call identifier argument_list identifier binary_operator string string_start string_content string_end tuple identifier return_statement identifier
Preprocess the token component of a token definition.
def draw_header(canvas): canvas.setStrokeColorRGB(0.9, 0.5, 0.2) canvas.setFillColorRGB(0.2, 0.2, 0.2) canvas.setFont('Helvetica', 16) canvas.drawString(18 * cm, -1 * cm, 'Invoice') canvas.drawInlineImage(settings.INV_LOGO, 1 * cm, -1 * cm, 250, 16) canvas.setLineWidth(4) canvas.line(0, -1.25 * cm, 21.7 * cm, -1.25 * cm)
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list float float float expression_statement call attribute identifier identifier argument_list float float float expression_statement call attribute identifier identifier argument_list string string_start string_content string_end integer expression_statement call attribute identifier identifier argument_list binary_operator integer identifier binary_operator unary_operator integer identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list attribute identifier identifier binary_operator integer identifier binary_operator unary_operator integer identifier integer integer expression_statement call attribute identifier identifier argument_list integer expression_statement call attribute identifier identifier argument_list integer binary_operator unary_operator float identifier binary_operator float identifier binary_operator unary_operator float identifier
Draws the invoice header
def _init_matrix(self, data, index, columns, dtype=None): data = prep_ndarray(data, copy=False) index, columns = self._prep_index(data, index, columns) data = {idx: data[:, i] for i, idx in enumerate(columns)} return self._init_dict(data, index, columns, dtype)
module function_definition identifier parameters identifier identifier identifier identifier default_parameter identifier none block expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier false expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier identifier identifier expression_statement assignment identifier dictionary_comprehension pair identifier subscript identifier slice identifier for_in_clause pattern_list identifier identifier call identifier argument_list identifier return_statement call attribute identifier identifier argument_list identifier identifier identifier identifier
Init self from ndarray or list of lists.
def close(self): if self._protocol is not None: self._protocol.processor.close() del self._protocol
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list delete_statement attribute identifier identifier
Closes connection to the server.
def setPoint(self, targetTemp): self.targetTemp = targetTemp self.Integrator = 0 self.Derivator = 0
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier integer
Initilize the setpoint of PID.
def _closure_parent_pk(self): if hasattr(self, "%s_id" % self._closure_parent_attr): return getattr(self, "%s_id" % self._closure_parent_attr) else: parent = getattr(self, self._closure_parent_attr) return parent.pk if parent else None
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier binary_operator string string_start string_content string_end attribute identifier identifier block return_statement call identifier argument_list identifier binary_operator string string_start string_content string_end attribute identifier identifier else_clause block expression_statement assignment identifier call identifier argument_list identifier attribute identifier identifier return_statement conditional_expression attribute identifier identifier identifier none
What our parent pk is in the closure tree.
def generate_query(self): query = Q() ORed = [] for form in self._non_deleted_forms: if not hasattr(form, 'cleaned_data'): continue if form.cleaned_data['field'] == "_OR": ORed.append(query) query = Q() else: query = query & form.make_query() if ORed: if query: ORed.append(query) query = reduce(operator.or_, ORed) return query
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier list for_statement identifier attribute identifier identifier block if_statement not_operator call identifier argument_list identifier string string_start string_content string_end block continue_statement if_statement comparison_operator subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list else_clause block expression_statement assignment identifier binary_operator identifier call attribute identifier identifier argument_list if_statement identifier block if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier identifier return_statement identifier
Reduces multiple queries into a single usable query
def update(self): if "tag_groups" not in self._device_dict: return for group in self.tag_groups: group.update() for i in range(len(self._device_dict["tag_groups"])): tag_group_dict = self._device_dict["tag_groups"][i] for group in self.tag_groups: if group.name == tag_group_dict["common.ALLTYPES_NAME"]: self._device_dict["tag_groups"][i] = group.as_dict()
module function_definition identifier parameters identifier block if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block return_statement for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list for_statement identifier call identifier argument_list call identifier argument_list subscript attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier subscript subscript attribute identifier identifier string string_start string_content string_end identifier for_statement identifier attribute identifier identifier block if_statement comparison_operator attribute identifier identifier subscript 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 call attribute identifier identifier argument_list
Updates the dictionary of the device
def send_registered_email(self, user, user_email, request_email_confirmation): if not self.user_manager.USER_ENABLE_EMAIL: return if not self.user_manager.USER_SEND_REGISTERED_EMAIL: return email = user_email.email if user_email else user.email if request_email_confirmation: token = self.user_manager.generate_token(user_email.id if user_email else user.id) confirm_email_link = url_for('user.confirm_email', token=token, _external=True) else: confirm_email_link = None self._render_and_send_email( email, user, self.user_manager.USER_REGISTERED_EMAIL_TEMPLATE, confirm_email_link=confirm_email_link, )
module function_definition identifier parameters identifier identifier identifier identifier block if_statement not_operator attribute attribute identifier identifier identifier block return_statement if_statement not_operator attribute attribute identifier identifier identifier block return_statement expression_statement assignment identifier conditional_expression attribute identifier identifier identifier attribute identifier identifier if_statement identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list conditional_expression attribute identifier identifier identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier true else_clause block expression_statement assignment identifier none expression_statement call attribute identifier identifier argument_list identifier identifier attribute attribute identifier identifier identifier keyword_argument identifier identifier
Send the 'user has registered' notification email.
def browse(ctx): page_html = Path(ctx.config.sphinx.destdir)/"html"/"index.html" if not page_html.exists(): build(ctx, builder="html") assert page_html.exists() open_cmd = "open" if sys.platform.startswith("win"): open_cmd = "start" ctx.run("{open} {page_html}".format(open=open_cmd, page_html=page_html))
module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator binary_operator call identifier argument_list attribute attribute attribute identifier identifier identifier identifier string string_start string_content string_end string string_start string_content string_end if_statement not_operator call attribute identifier identifier argument_list block expression_statement call identifier argument_list identifier keyword_argument identifier string string_start string_content string_end assert_statement call attribute identifier identifier argument_list expression_statement assignment identifier string string_start string_content string_end if_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier
Open documentation in web browser.
def process(self, request, item): warn_untested() from paypal.pro.helpers import PayPalWPP wpp = PayPalWPP(request) params = model_to_dict(self, exclude=self.ADMIN_FIELDS) params['acct'] = self.acct params['creditcardtype'] = self.creditcardtype params['expdate'] = self.expdate params['cvv2'] = self.cvv2 params.update(item) if 'billingperiod' in params: return wpp.createRecurringPaymentsProfile(params, direct=True) else: return wpp.doDirectPayment(params)
module function_definition identifier parameters identifier identifier identifier block expression_statement call identifier argument_list import_from_statement dotted_name identifier identifier identifier dotted_name identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier attribute identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier if_statement comparison_operator string string_start string_content string_end identifier block return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier true else_clause block return_statement call attribute identifier identifier argument_list identifier
Do a direct payment.
def quit(self): try: self._client.write(sc_pb.Request(quit=sc_pb.RequestQuit())) except protocol.ConnectionError: pass finally: self.close()
module function_definition identifier parameters identifier block try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list except_clause attribute identifier identifier block pass_statement finally_clause block expression_statement call attribute identifier identifier argument_list
Shut down the SC2 process.
def to_json(self, extras=None): extras = extras or {} to_dict = model_to_dict(self) to_dict.update(extras) return json.dumps(to_dict, cls=sel.serializers.JsonEncoder)
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier boolean_operator identifier dictionary expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier attribute attribute identifier identifier identifier
Convert a model into a json using the playhouse shortcut.
def _parse_config(config_file_path): config_file = open(config_file_path, 'r') config = yaml.load(config_file) config_file.close() return config
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list return_statement identifier
Parse Config File from yaml file.
def log_url (self, url_data, priority=None): self.xml_starttag(u'url') self.xml_tag(u'loc', url_data.url) if url_data.modified: self.xml_tag(u'lastmod', self.format_modified(url_data.modified, sep="T")) self.xml_tag(u'changefreq', self.frequency) self.xml_tag(u'priority', "%.2f" % priority) self.xml_endtag(u'url') self.flush()
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end binary_operator string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list
Log URL data in sitemap format.
def create_permissions(): current_app.appbuilder.add_permissions(update_perms=True) click.echo(click.style("Created all permissions", fg="green"))
module function_definition identifier parameters block expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier true expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end
Creates all permissions and add them to the ADMIN Role.
def from_group(cls, group): if not group: return tag_items = group.split(";") return list(map(cls.parse, tag_items))
module function_definition identifier parameters identifier identifier block if_statement not_operator identifier block return_statement expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end return_statement call identifier argument_list call identifier argument_list attribute identifier identifier identifier
Construct tags from the regex group
def to_unit(value, unit='B'): byte_array = ['B', 'KB', 'MB', 'GB', 'TB'] if not isinstance(value, (int, float)): value = float(value) if unit in byte_array: result = value / 1024**byte_array.index(unit) return round(result, PRECISION), unit return value
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end if_statement not_operator call identifier argument_list identifier tuple identifier identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier identifier block expression_statement assignment identifier binary_operator identifier binary_operator integer call attribute identifier identifier argument_list identifier return_statement expression_list call identifier argument_list identifier identifier identifier return_statement identifier
Convert bytes to give unit.
def _SetupBotoConfig(self): project_id = self._GetNumericProjectId() try: boto_config.BotoConfig(project_id, debug=self.debug) except (IOError, OSError) as e: self.logger.warning(str(e))
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list try_statement block expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier except_clause as_pattern tuple identifier identifier as_pattern_target identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list identifier
Set the boto config so GSUtil works with provisioned service accounts.
def openEmbedded(self, name): ndx = self.toc.find(name) if ndx == -1: raise KeyError, "Member '%s' not found in %s" % (name, self.path) (dpos, dlen, ulen, flag, typcd, nm) = self.toc.get(ndx) if flag: raise ValueError, "Cannot open compressed archive %s in place" return CArchive(self.path, self.pkgstart+dpos, dlen)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator identifier unary_operator integer block raise_statement expression_list identifier binary_operator string string_start string_content string_end tuple identifier attribute identifier identifier expression_statement assignment tuple_pattern identifier identifier identifier identifier identifier identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement identifier block raise_statement expression_list identifier string string_start string_content string_end return_statement call identifier argument_list attribute identifier identifier binary_operator attribute identifier identifier identifier identifier
Open a CArchive of name NAME embedded within this CArchive.
def _xorterm(lexer): prodterm = _prodterm(lexer) xorterm_prime = _xorterm_prime(lexer) if xorterm_prime is None: return prodterm else: return ('xor', prodterm, xorterm_prime)
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier none block return_statement identifier else_clause block return_statement tuple string string_start string_content string_end identifier identifier
Return an xor term expresssion.
def _symmetric_warp(c, magnitude:partial(uniform,size=4)=0, invert=False): "Apply symmetric warp of `magnitude` to `c`." m = listify(magnitude, 4) targ_pts = [[-1-m[3],-1-m[1]], [-1-m[2],1+m[1]], [1+m[3],-1-m[0]], [1+m[2],1+m[0]]] return _do_perspective_warp(c, targ_pts, invert)
module function_definition identifier parameters identifier typed_default_parameter identifier type call identifier argument_list identifier keyword_argument identifier integer integer default_parameter identifier false block expression_statement string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier integer expression_statement assignment identifier list list binary_operator unary_operator integer subscript identifier integer binary_operator unary_operator integer subscript identifier integer list binary_operator unary_operator integer subscript identifier integer binary_operator integer subscript identifier integer list binary_operator integer subscript identifier integer binary_operator unary_operator integer subscript identifier integer list binary_operator integer subscript identifier integer binary_operator integer subscript identifier integer return_statement call identifier argument_list identifier identifier identifier
Apply symmetric warp of `magnitude` to `c`.
def model_changed(self, model, prop_name, info): if self.parent is not None: self.parent.model_changed(model, prop_name, info)
module function_definition identifier parameters identifier identifier identifier identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier identifier
This method notifies the parent state about changes made to the state element
def contract(self): if self.is_root(): return for c in self.children: if self.edge_length is not None and c.edge_length is not None: c.edge_length += self.edge_length self.parent.add_child(c) self.parent.remove_child(self)
module function_definition identifier parameters identifier block if_statement call attribute identifier identifier argument_list block return_statement for_statement identifier attribute identifier identifier block if_statement boolean_operator comparison_operator attribute identifier identifier none comparison_operator attribute identifier identifier none block expression_statement augmented_assignment attribute identifier identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Contract this ``Node`` by directly connecting its children to its parent
def iiif_image_key(obj): if isinstance(obj, ObjectVersion): bucket_id = obj.bucket_id version_id = obj.version_id key = obj.key else: bucket_id = obj.get('bucket') version_id = obj.get('version_id') key = obj.get('key') return u'{}:{}:{}'.format( bucket_id, version_id, key, )
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end return_statement call attribute string string_start string_content string_end identifier argument_list identifier identifier identifier
Generate the IIIF image key.
def int_to_base36(i): if six.PY2: char_set = '0123456789abcdefghijklmnopqrstuvwxyz' if i < 0: raise ValueError("Negative base36 conversion input.") if not isinstance(i, six.integer_types): raise TypeError("Non-integer base36 conversion input.") if i < 36: return char_set[i] b36 = '' while i != 0: i, n = divmod(i, 36) b36 = char_set[n] + b36 else: from django.utils.http import int_to_base36 b36 = int_to_base36(i) return b36
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block expression_statement assignment identifier 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 not_operator call identifier argument_list identifier attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier integer block return_statement subscript identifier identifier expression_statement assignment identifier string string_start string_end while_statement comparison_operator identifier integer block expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier integer expression_statement assignment identifier binary_operator subscript identifier identifier identifier else_clause block import_from_statement dotted_name identifier identifier identifier dotted_name identifier expression_statement assignment identifier call identifier argument_list identifier return_statement identifier
Django on py2 raises ValueError on large values.
def remove_empty_dirs(path=None): if not path: path = settings.MEDIA_ROOT if not os.path.isdir(path): return False listdir = [os.path.join(path, filename) for filename in os.listdir(path)] if all(list(map(remove_empty_dirs, listdir))): os.rmdir(path) return True else: return False
module function_definition identifier parameters default_parameter identifier none block if_statement not_operator identifier block expression_statement assignment identifier attribute identifier identifier if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block return_statement false expression_statement assignment identifier list_comprehension call attribute attribute identifier identifier identifier argument_list identifier identifier for_in_clause identifier call attribute identifier identifier argument_list identifier if_statement call identifier argument_list call identifier argument_list call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement true else_clause block return_statement false
Recursively delete empty directories; return True if everything was deleted.
def broadcast_url(self, broadcast_id=None, stop=False, layout=False): url = self.api_url + '/v2/project/' + self.api_key + '/broadcast' if broadcast_id: url = url + '/' + broadcast_id if stop: url = url + '/stop' if layout: url = url + '/layout' return url
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier false default_parameter identifier false block expression_statement assignment identifier binary_operator binary_operator binary_operator attribute identifier identifier string string_start string_content string_end attribute identifier identifier string string_start string_content string_end if_statement identifier block expression_statement assignment identifier binary_operator binary_operator identifier string string_start string_content string_end identifier if_statement identifier block expression_statement assignment identifier binary_operator identifier string string_start string_content string_end if_statement identifier block expression_statement assignment identifier binary_operator identifier string string_start string_content string_end return_statement identifier
this method returns urls for working with broadcast
def with_decode(self, decode=True): return Nvim(self._session, self.channel_id, self.metadata, self.types, decode, self._err_cb)
module function_definition identifier parameters identifier default_parameter identifier true block return_statement call identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier identifier attribute identifier identifier
Initialize a new Nvim instance.
def main(self) -> None: path = ask_path("where should the config be stored?", ".snekrc") conf = configobj.ConfigObj() tools = self.get_tools() for tool in tools: conf[tool] = getattr(self, tool)() conf.filename = path conf.write() print("Written config file!") if "pylint" in tools: print( "Please also run `pylint --generate-rcfile` to complete setup")
module function_definition identifier parameters identifier type none block expression_statement assignment identifier call identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list for_statement identifier identifier block expression_statement assignment subscript identifier identifier call call identifier argument_list identifier identifier argument_list expression_statement assignment attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement call identifier argument_list string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end identifier block expression_statement call identifier argument_list string string_start string_content string_end
The main function for generating the config file
def create_handler(target: str): if target == 'stderr': return logging.StreamHandler(sys.stderr) elif target == 'stdout': return logging.StreamHandler(sys.stdout) else: return logging.handlers.WatchedFileHandler(filename=target)
module function_definition identifier parameters typed_parameter identifier type identifier block if_statement comparison_operator identifier string string_start string_content string_end block return_statement call attribute identifier identifier argument_list attribute identifier identifier elif_clause comparison_operator identifier string string_start string_content string_end block return_statement call attribute identifier identifier argument_list attribute identifier identifier else_clause block return_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier
Create a handler for logging to ``target``
def insert_system_path(opts, paths): if isinstance(paths, six.string_types): paths = [paths] for path in paths: path_options = {'path': path, 'root_dir': opts['root_dir']} prepend_root_dir(path_options, path_options) if (os.path.isdir(path_options['path']) and path_options['path'] not in sys.path): sys.path.insert(0, path_options['path'])
module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier attribute identifier identifier block expression_statement assignment identifier list identifier for_statement identifier identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement call identifier argument_list identifier identifier if_statement parenthesized_expression boolean_operator call attribute attribute identifier identifier identifier argument_list subscript identifier string string_start string_content string_end comparison_operator subscript identifier string string_start string_content string_end attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list integer subscript identifier string string_start string_content string_end
Inserts path into python path taking into consideration 'root_dir' option.
def jsonp(data, **json_kwargs): from uliweb import request if 'jsonp' in json_kwargs: cb = json_kwargs.pop('jsonp') else: cb = 'callback' begin = str(request.GET.get(cb)) if not begin: raise BadRequest("Can't found %s parameter in request's query_string" % cb) if not r_callback.match(begin): raise BadRequest("The callback name is not right, it can be alphabetic, number and underscore only") if callable(data): @wraps(data) def f(*arg, **kwargs): ret = data(*arg, **kwargs) return Response(begin + '(' + json_dumps(ret) + ');', **json_kwargs) return f else: return Response(begin + '(' + json_dumps(data) + ');', **json_kwargs)
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block import_from_statement dotted_name identifier dotted_name identifier if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end else_clause block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier if_statement not_operator identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier if_statement not_operator call attribute identifier identifier argument_list identifier block raise_statement call identifier argument_list string string_start string_content string_end if_statement call identifier argument_list identifier block decorated_definition decorator call identifier argument_list identifier function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list list_splat identifier dictionary_splat identifier return_statement call identifier argument_list 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 dictionary_splat identifier return_statement identifier else_clause block return_statement call identifier argument_list 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 dictionary_splat identifier
jsonp is callback key name
def param_fetch_all(self): if time.time() - getattr(self, 'param_fetch_start', 0) < 2.0: return self.param_fetch_start = time.time() self.param_fetch_in_progress = True self.mav.param_request_list_send(self.target_system, self.target_component)
module function_definition identifier parameters identifier block if_statement comparison_operator binary_operator call attribute identifier identifier argument_list call identifier argument_list identifier string string_start string_content string_end integer float block return_statement expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier true expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier attribute identifier identifier
initiate fetch of all parameters
def put_file(self, filename, index, doc_type, id=None, name=None): if id is None: request_method = 'POST' else: request_method = 'PUT' path = make_path(index, doc_type, id) doc = file_to_attachment(filename) if name: doc["_name"] = name return self._send_request(request_method, path, doc)
module function_definition identifier parameters identifier identifier identifier identifier default_parameter identifier none default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier string string_start string_content string_end else_clause block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier if_statement identifier block expression_statement assignment subscript identifier string string_start string_content string_end identifier return_statement call attribute identifier identifier argument_list identifier identifier identifier
Store a file in a index
def color_text(text, color="none", bcolor="none", effect="none"): istty = False try: istty = sys.stdout.isatty() except: pass if not istty or not COLOR_ON: return text else: if not effect in COLOR_EFFET.keys(): effect = "none" if not color in COLOR_CODE_TEXT.keys(): color = "none" if not bcolor in COLOR_CODE_BG.keys(): bcolor = "none" v_effect = COLOR_EFFET[effect] v_color = COLOR_CODE_TEXT[color] v_bcolor = COLOR_CODE_BG[bcolor] if effect == "none" and color == "none" and bcolor == "none": return text else: return "\033[%d;%d;%dm" % (v_effect, v_color, v_bcolor) + text + COLOR_RESET
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end default_parameter identifier string string_start string_content string_end default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier false try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list except_clause block pass_statement if_statement boolean_operator not_operator identifier not_operator identifier block return_statement identifier else_clause block if_statement not_operator comparison_operator identifier call attribute identifier identifier argument_list block expression_statement assignment identifier string string_start string_content string_end if_statement not_operator comparison_operator identifier call attribute identifier identifier argument_list block expression_statement assignment identifier string string_start string_content string_end if_statement not_operator comparison_operator identifier call attribute identifier identifier argument_list block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier identifier expression_statement assignment identifier subscript identifier identifier expression_statement assignment identifier subscript identifier identifier if_statement 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 return_statement identifier else_clause block return_statement binary_operator binary_operator binary_operator string string_start string_content escape_sequence string_end tuple identifier identifier identifier identifier identifier
Return a formated text with bash color
def remove_provenance_project_variables(): project_context_scope = QgsExpressionContextUtils.projectScope( QgsProject.instance()) existing_variable_names = project_context_scope.variableNames() existing_variables = {} for existing_variable_name in existing_variable_names: existing_variables[existing_variable_name] = \ project_context_scope.variable(existing_variable_name) for the_provenance in provenance_list: if the_provenance['provenance_key'] in existing_variables: existing_variables.pop(the_provenance['provenance_key']) will_be_removed = [] for existing_variable in existing_variables: for the_provenance in provenance_list: if existing_variable.startswith( the_provenance['provenance_key']): will_be_removed.append(existing_variable) continue for variable in will_be_removed: existing_variables.pop(variable) non_null_existing_variables = {} for k, v in list(existing_variables.items()): if v is None or (hasattr(v, 'isNull') and v.isNull()): non_null_existing_variables[k] = None else: non_null_existing_variables[k] = v QgsExpressionContextUtils.setProjectVariables( QgsProject.instance(), non_null_existing_variables)
module function_definition identifier parameters block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier dictionary for_statement identifier identifier block expression_statement assignment subscript identifier identifier line_continuation call attribute identifier identifier argument_list identifier for_statement identifier identifier block if_statement comparison_operator subscript identifier string string_start string_content string_end identifier block expression_statement call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end expression_statement assignment identifier list for_statement identifier identifier block for_statement identifier identifier block if_statement call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list identifier continue_statement for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier dictionary for_statement pattern_list identifier identifier call identifier argument_list call attribute identifier identifier argument_list block if_statement boolean_operator comparison_operator identifier none parenthesized_expression boolean_operator call identifier argument_list identifier string string_start string_content string_end call attribute identifier identifier argument_list block expression_statement assignment subscript identifier identifier none else_clause block expression_statement assignment subscript identifier identifier identifier expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier
Removing variables from provenance data.