code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def getArraysByName(elem, name): name = StripArrayName(name) return elem.getElements(lambda e: (e.tagName == ligolw.Array.tagName) and (e.Name == name))
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier return_statement call attribute identifier identifier argument_list lambda lambda_parameters identifier boolean_operator parenthesized_expression comparison_operator attribute identifier identifier attribute attribute identifier identifier identifier parenthesized_expression comparison_operator attribute identifier identifier identifier
Return a list of arrays with name name under elem.
def image_export(cls, source_path, dest_url, **kwargs): dest_path = urlparse.urlparse(dest_url).path if kwargs['remote_host']: target_path = ':'.join([kwargs['remote_host'], dest_path]) command = ' '.join(['/usr/bin/scp', "-P", CONF.zvm.remotehost_sshd_port, "-o StrictHostKeyChecking=no", '-r ', source_path, target_path]) (rc, output) = zvmutils.execute(command) if rc: msg = ("Error happened when copying image file to remote " "host with reason: %s" % output) LOG.error(msg) raise exception.SDKImageOperationError(rs=21, msg=output) else: LOG.debug("Remote_host not specified, will copy to local server") try: shutil.copyfile(source_path, dest_path) except Exception as err: msg = ("Export image from %(src)s to local file system" " %(dest)s failed: %(err)s" % {'src': source_path, 'dest': dest_path, 'err': six.text_type(err)}) LOG.error(msg) raise exception.SDKImageOperationError(rs=22, err=six.text_type(err))
module function_definition identifier parameters identifier identifier identifier dictionary_splat_pattern identifier block expression_statement assignment identifier attribute call attribute identifier identifier argument_list identifier identifier if_statement subscript identifier string string_start string_content string_end block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list list subscript identifier string string_start string_content string_end identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list list string string_start string_content string_end string string_start string_content string_end attribute attribute identifier identifier identifier string string_start string_content string_end string string_start string_content string_end identifier identifier expression_statement assignment tuple_pattern identifier identifier call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement assignment identifier parenthesized_expression binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier raise_statement call attribute identifier identifier argument_list keyword_argument identifier integer keyword_argument identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end try_statement block expression_statement call attribute identifier identifier argument_list identifier identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement assignment identifier parenthesized_expression binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier raise_statement call attribute identifier identifier argument_list keyword_argument identifier integer keyword_argument identifier call attribute identifier identifier argument_list identifier
Export the specific image to remote host or local file system
def _syntax_style_changed(self): if self._highlighter is None: return if self.syntax_style: self._highlighter._style = create_style_class(self.syntax_style) self._highlighter._clear_caches() else: self._highlighter.set_style_sheet(self.style_sheet)
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block return_statement if_statement attribute identifier identifier block expression_statement assignment attribute attribute identifier identifier identifier call identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier
Refresh the highlighting with the current syntax style by class.
def remove_all_files_of_img_id(img_id): files = get_files_by_img_id(img_id, check_hash=False) if files: os.remove(media_path(files['main'])) for fn in files['variants'].values(): os.remove(media_path(fn))
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier false if_statement identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list subscript identifier string string_start string_content string_end for_statement identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier
Removes all img_id's files.
def _log_python_version(self): self.log.info( u'Python Version: {}.{}.{}'.format( sys.version_info.major, sys.version_info.minor, sys.version_info.micro ) )
module function_definition identifier parameters 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 attribute identifier identifier identifier attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier
Log the current Python version.
def configure(): log_levels = { 5: logging.NOTSET, 4: logging.DEBUG, 3: logging.INFO, 2: logging.WARNING, 1: logging.ERROR, 0: logging.CRITICAL } logging.captureWarnings(True) root_logger = logging.getLogger() if settings.CFG["debug"]: details_format = logging.Formatter( '%(name)s (%(filename)s:%(lineno)s) [%(levelname)s] %(message)s') details_hdl = logging.StreamHandler() details_hdl.setFormatter(details_format) root_logger.addHandler(details_hdl) else: brief_format = logging.Formatter('%(message)s') console_hdl = logging.StreamHandler() console_hdl.setFormatter(brief_format) root_logger.addHandler(console_hdl) root_logger.setLevel(log_levels[int(settings.CFG["verbosity"])]) configure_plumbum_log() configure_migrate_log() configure_parse_log()
module function_definition identifier parameters block expression_statement assignment identifier dictionary pair integer attribute identifier identifier pair integer attribute identifier identifier pair integer attribute identifier identifier pair integer attribute identifier identifier pair integer attribute identifier identifier pair integer attribute identifier identifier expression_statement call attribute identifier identifier argument_list true expression_statement assignment identifier call attribute identifier identifier argument_list if_statement subscript attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier 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 expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list subscript identifier call identifier argument_list subscript attribute identifier identifier string string_start string_content string_end expression_statement call identifier argument_list expression_statement call identifier argument_list expression_statement call identifier argument_list
Load logging configuration from our own defaults.
def validate(tool_class, model_class): if not hasattr(tool_class, 'name'): raise ImproperlyConfigured("No 'name' attribute found for tool %s." % ( tool_class.__name__ )) if not hasattr(tool_class, 'label'): raise ImproperlyConfigured("No 'label' attribute found for tool %s." % ( tool_class.__name__ )) if not hasattr(tool_class, 'view'): raise NotImplementedError("No 'view' method found for tool %s." % ( tool_class.__name__ ))
module function_definition identifier parameters identifier identifier block if_statement not_operator call identifier argument_list identifier string string_start string_content string_end block raise_statement call identifier argument_list binary_operator string string_start string_content string_end parenthesized_expression attribute identifier identifier if_statement not_operator call identifier argument_list identifier string string_start string_content string_end block raise_statement call identifier argument_list binary_operator string string_start string_content string_end parenthesized_expression attribute identifier identifier if_statement not_operator call identifier argument_list identifier string string_start string_content string_end block raise_statement call identifier argument_list binary_operator string string_start string_content string_end parenthesized_expression attribute identifier identifier
Does basic ObjectTool option validation.
def transfer_owner(self, new_owner): if not self.owner and not self.admin: raise RuntimeError("You need more street creed to do this") new_owner = new_owner.strip().lower() if not new_owner: raise ValueError("Empty strings cannot be new owners") self.__set_config_value("owner", new_owner)
module function_definition identifier parameters identifier identifier block if_statement boolean_operator not_operator attribute identifier identifier not_operator attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list if_statement not_operator identifier block raise_statement call 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 identifier
You had good run at it, it's time for someone else to get dirty
def PrintErrorCounts(self): for category, count in self.errors_by_category.iteritems(): sys.stderr.write('Category \'%s\' errors found: %d\n' % (category, count)) sys.stderr.write('Total errors found: %d\n' % self.error_count)
module function_definition identifier parameters identifier block for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content escape_sequence escape_sequence escape_sequence string_end tuple identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content escape_sequence string_end attribute identifier identifier
Print a summary of errors by category, and the total.
def process_boolean(self, tag): tag.set_address(self.normal_register.current_bit_address) self.normal_register.move_to_next_bit_address()
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list attribute attribute identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list
Process Boolean type tags
def _render_string(self, template, *context, **kwargs): template = self._to_unicode_hard(template) render_func = lambda engine, stack: engine.render(template, stack) return self._render_final(render_func, *context, **kwargs)
module function_definition identifier parameters identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier lambda lambda_parameters identifier identifier call attribute identifier identifier argument_list identifier identifier return_statement call attribute identifier identifier argument_list identifier list_splat identifier dictionary_splat identifier
Render the given template string using the given context.
def freeze(dest_dir, opt): tmp_dir = ensure_tmpdir() dest_prefix = "%s/dest" % tmp_dir ensure_dir(dest_dir) ensure_dir(dest_prefix) config = get_secretfile(opt) Context.load(config, opt) \ .freeze(dest_prefix) zip_filename = freeze_archive(tmp_dir, dest_prefix) ice_file = freeze_encrypt(dest_dir, zip_filename, config, opt) shutil.rmtree(tmp_dir) LOG.debug("Generated file is %s", ice_file)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier binary_operator string string_start string_content string_end identifier expression_statement call identifier argument_list identifier expression_statement call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute call attribute identifier identifier argument_list identifier identifier line_continuation identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier
Iterates over the Secretfile looking for secrets to freeze
def _maybe_append_chunk(chunk_info, line_index, column, contents, chunks): if chunk_info: chunks.append(_chunk_from_ranges(contents, chunk_info[0], chunk_info[1], line_index, column))
module function_definition identifier parameters identifier identifier identifier identifier identifier block if_statement identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier subscript identifier integer subscript identifier integer identifier identifier
Append chunk_info to chunks if it is set.
def pop_scope(self): child_scope = self.stack.current.current.copy() self.stack.current.pop() parent_scope = self.stack.current.current.copy() self.stack.current.current = { key: child_scope[key] for key in child_scope if key in parent_scope }
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute attribute attribute identifier identifier identifier identifier identifier argument_list expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list expression_statement assignment identifier call attribute attribute attribute attribute identifier identifier identifier identifier identifier argument_list expression_statement assignment attribute attribute attribute identifier identifier identifier identifier dictionary_comprehension pair identifier subscript identifier identifier for_in_clause identifier identifier if_clause comparison_operator identifier identifier
Delete the current scope in the current scope.
def _consume_errback(failure): global _exit_code if failure.check(exceptions.BadDeclaration): _log.error( "Unable to declare the %s object on the AMQP broker. The " "broker responded with %s. Check permissions for your user.", failure.value.obj_type, failure.value.reason, ) _exit_code = 10 elif failure.check(exceptions.PermissionException): _exit_code = 15 _log.error( "The consumer could not proceed because of a permissions problem: %s", str(failure.value), ) elif failure.check(exceptions.ConnectionException): _exit_code = 14 _log.error(failure.value.reason) else: _exit_code = 11 _log.exception( "An unexpected error (%r) occurred while registering the " "consumer, please report this bug.", failure.value, ) try: reactor.stop() except error.ReactorNotRunning: pass
module function_definition identifier parameters identifier block global_statement identifier if_statement call attribute identifier identifier argument_list attribute identifier identifier block expression_statement call attribute identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier expression_statement assignment identifier integer elif_clause call attribute identifier identifier argument_list attribute identifier identifier block expression_statement assignment identifier integer expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list attribute identifier identifier elif_clause call attribute identifier identifier argument_list attribute identifier identifier block expression_statement assignment identifier integer expression_statement call attribute identifier identifier argument_list attribute attribute identifier identifier identifier else_clause block expression_statement assignment identifier integer expression_statement call attribute identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end attribute identifier identifier try_statement block expression_statement call attribute identifier identifier argument_list except_clause attribute identifier identifier block pass_statement
Handle any errors that occur during consumer registration.
def createDatabase(self, name, **dbArgs) : "use dbArgs for arguments other than name. for a full list of arguments please have a look at arangoDB's doc" dbArgs['name'] = name payload = json.dumps(dbArgs, default=str) url = self.URL + "/database" r = self.session.post(url, data = payload) data = r.json() if r.status_code == 201 and not data["error"] : db = Database(self, name) self.databases[name] = db return self.databases[name] else : raise CreationError(data["errorMessage"], r.content)
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block expression_statement string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier expression_statement assignment identifier binary_operator attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list if_statement boolean_operator comparison_operator attribute identifier identifier integer not_operator subscript identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment subscript attribute identifier identifier identifier identifier return_statement subscript attribute identifier identifier identifier else_clause block raise_statement call identifier argument_list subscript identifier string string_start string_content string_end attribute identifier identifier
use dbArgs for arguments other than name. for a full list of arguments please have a look at arangoDB's doc
def store_value(self, name, value): self.spine.send_command("storeSetting", self.group, name, value)
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end attribute identifier identifier identifier identifier
Store a value to DB
def _examine_val(self, k, val): 'should only be called internally' if not isinstance(val, (types.FunctionType, partial)): return val vid = id(val) if vid in self._memoized: return self._memoized[vid] elif [] != getargspec_py27like(val)[0]: return val else: val = val() object.__setattr__(self, '_memoized', self._memoized.set(vid, val)) return val
module function_definition identifier parameters identifier identifier identifier block expression_statement string string_start string_content string_end if_statement not_operator call identifier argument_list identifier tuple attribute identifier identifier identifier block return_statement identifier expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier attribute identifier identifier block return_statement subscript attribute identifier identifier identifier elif_clause comparison_operator list subscript call identifier argument_list identifier integer block return_statement identifier else_clause block expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list identifier string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list identifier identifier return_statement identifier
should only be called internally
def consume(self, msg): log.debug("Got message %r" % msg) topic, body = msg.get('topic'), msg.get('body') for client in self.irc_clients: if not client.factory.filters or ( client.factory.filters and self.apply_filters(client.factory.filters, topic, body) ): raw_msg = self.prettify( topic=topic, msg=body, pretty=client.factory.pretty, terse=client.factory.terse, short=client.factory.short, ) send = getattr(client, self.hub.config['irc_method'], 'notice') send(client.factory.channel, raw_msg.encode('utf-8')) backlog = self.incoming.qsize() if backlog and (backlog % 20) == 0: warning = "* backlogged by %i messages" % backlog log.warning(warning) send(client.factory.channel, warning.encode('utf-8'))
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement assignment pattern_list identifier identifier expression_list call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end for_statement identifier attribute identifier identifier block if_statement boolean_operator not_operator attribute attribute identifier identifier identifier parenthesized_expression boolean_operator attribute attribute identifier identifier identifier call attribute identifier identifier argument_list attribute attribute identifier identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier subscript attribute attribute identifier identifier identifier string string_start string_content string_end string string_start string_content string_end expression_statement call identifier argument_list attribute attribute identifier identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list if_statement boolean_operator identifier comparison_operator parenthesized_expression binary_operator identifier integer integer block expression_statement assignment identifier binary_operator string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call identifier argument_list attribute attribute identifier identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end
Forward on messages from the bus to all IRC connections.
def sort(self, cmp=None, key=None, reverse=False): if not key and self._keys: key = self.KeyValue super(CliTable, self).sort(cmp=cmp, key=key, reverse=reverse)
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier false block if_statement boolean_operator not_operator identifier attribute identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement call attribute call identifier argument_list identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
Overrides sort func to use the KeyValue for the key.
def import_class(class_path): module_name, class_name = class_path.rsplit(".", 1) module = import_module(module_name) claz = getattr(module, class_name) return claz
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end integer expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier identifier return_statement identifier
Imports the class for the given class name.
def extract_payload(self, request, verify=True, *args, **kwargs): payload = self._verify( request, return_payload=True, verify=verify, *args, **kwargs ) return payload
module function_definition identifier parameters identifier identifier default_parameter identifier true list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier true keyword_argument identifier identifier list_splat identifier dictionary_splat identifier return_statement identifier
Extract a payload from a request object.
def rpyhttp(value): if value.startswith("http"): return value try: parts = value.split("_") del parts[0] _uri = base64.b64decode(parts.pop(0)).decode() return _uri + "_".join(parts) except (IndexError, UnicodeDecodeError, binascii.Error): return value
module function_definition identifier parameters identifier block if_statement call attribute identifier identifier argument_list string string_start string_content string_end block return_statement identifier try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end delete_statement subscript identifier integer expression_statement assignment identifier call attribute call attribute identifier identifier argument_list call attribute identifier identifier argument_list integer identifier argument_list return_statement binary_operator identifier call attribute string string_start string_content string_end identifier argument_list identifier except_clause tuple identifier identifier attribute identifier identifier block return_statement identifier
converts a no namespace pyuri back to a standard uri
def getBoneHierarchy(self, action, unIndexArayCount): fn = self.function_table.getBoneHierarchy pParentIndices = BoneIndex_t() result = fn(action, byref(pParentIndices), unIndexArayCount) return result, pParentIndices
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 expression_statement assignment identifier call identifier argument_list identifier call identifier argument_list identifier identifier return_statement expression_list identifier identifier
Fills the given array with the index of each bone's parent in the skeleton associated with the given action
def to_detach(b:Tensors, cpu:bool=True): "Recursively detach lists of tensors in `b `; put them on the CPU if `cpu=True`." if is_listy(b): return [to_detach(o, cpu) for o in b] if not isinstance(b,Tensor): return b b = b.detach() return b.cpu() if cpu else b
module function_definition identifier parameters typed_parameter identifier type identifier typed_default_parameter identifier type identifier true block expression_statement string string_start string_content string_end if_statement call identifier argument_list identifier block return_statement list_comprehension call identifier argument_list identifier identifier for_in_clause identifier identifier if_statement not_operator call identifier argument_list identifier identifier block return_statement identifier expression_statement assignment identifier call attribute identifier identifier argument_list return_statement conditional_expression call attribute identifier identifier argument_list identifier identifier
Recursively detach lists of tensors in `b `; put them on the CPU if `cpu=True`.
def graphql_queries_to_json(*queries): rtn = {} for i, query in enumerate(queries): rtn["q{}".format(i)] = query.value return json.dumps(rtn)
module function_definition identifier parameters list_splat_pattern identifier block expression_statement assignment identifier dictionary for_statement pattern_list identifier identifier call identifier argument_list identifier block expression_statement assignment subscript identifier call attribute string string_start string_content string_end identifier argument_list identifier attribute identifier identifier return_statement call attribute identifier identifier argument_list identifier
Queries should be a list of GraphQL objects
def __put_slice_in_slim(slim, dataim, sh, i): a, b = np.unravel_index(int(i), sh) st0 = int(dataim.shape[0] * a) st1 = int(dataim.shape[1] * b) sp0 = int(st0 + dataim.shape[0]) sp1 = int(st1 + dataim.shape[1]) slim[ st0:sp0, st1:sp1 ] = dataim return slim
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list call identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list binary_operator subscript attribute identifier identifier integer identifier expression_statement assignment identifier call identifier argument_list binary_operator subscript attribute identifier identifier integer identifier expression_statement assignment identifier call identifier argument_list binary_operator identifier subscript attribute identifier identifier integer expression_statement assignment identifier call identifier argument_list binary_operator identifier subscript attribute identifier identifier integer expression_statement assignment subscript identifier slice identifier identifier slice identifier identifier identifier return_statement identifier
put one small slice as a tile in a big image
def executeSQL(self, sql, args=()): sql = self._execSQL(sql, args) result = self.cursor.lastRowID() if self.executedThisTransaction is not None: self.executedThisTransaction.append((result, sql, args)) return result
module function_definition identifier parameters identifier identifier default_parameter identifier tuple block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list tuple identifier identifier identifier return_statement identifier
For use with UPDATE or INSERT statements.
def _len_ea_entry(self): return EaEntry._REPR.size + len(self.name.encode("ascii")) + self.value_len
module function_definition identifier parameters identifier block return_statement binary_operator binary_operator attribute attribute identifier identifier identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end attribute identifier identifier
Returns the size of the entry
def execute_command(command=None): process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stdin = process.communicate() process.wait() return (stdout, stdin), process.returncode
module function_definition identifier parameters default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list return_statement expression_list tuple identifier identifier attribute identifier identifier
Execute a command and return the stdout and stderr.
def reset_script(self): self.remote_bridge.status = BRIDGE_STATUS.IDLE self.remote_bridge.error = 0 self.remote_bridge.parsed_script = None self._device.script = bytearray() return [0]
module function_definition identifier parameters identifier block expression_statement assignment attribute attribute identifier identifier identifier attribute identifier identifier expression_statement assignment attribute attribute identifier identifier identifier integer expression_statement assignment attribute attribute identifier identifier identifier none expression_statement assignment attribute attribute identifier identifier identifier call identifier argument_list return_statement list integer
Clear any partially received script.
def render_in_browser(self, **kwargs): try: from lxml.html import open_in_browser except ImportError: raise ImportError('You must install lxml to use render in browser') kwargs.setdefault('force_uri_protocol', 'https') open_in_browser(self.render_tree(**kwargs), encoding='utf-8')
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block try_statement block import_from_statement dotted_name identifier identifier dotted_name identifier except_clause identifier block raise_statement call 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 string string_start string_content string_end expression_statement call identifier argument_list call attribute identifier identifier argument_list dictionary_splat identifier keyword_argument identifier string string_start string_content string_end
Render the graph, open it in your browser with black magic
def add(assetclass: int, symbol: str): assert isinstance(symbol, str) assert isinstance(assetclass, int) symbol = symbol.upper() app = AppAggregate() new_item = app.add_stock_to_class(assetclass, symbol) print(f"Record added: {new_item}.")
module function_definition identifier parameters typed_parameter identifier type identifier typed_parameter identifier type identifier block assert_statement call identifier argument_list identifier identifier assert_statement call identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement call identifier argument_list string string_start string_content interpolation identifier string_content string_end
Add a stock to an asset class
async def queue_declare(self): await self.channel.queue_declare( self.queue, durable=self.durable, exclusive=self.exclusive, no_wait=self.no_wait )
module function_definition identifier parameters identifier block expression_statement await call attribute attribute identifier identifier identifier argument_list attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier
Override this method to change how a queue is declared
def remaining_time(self): elapsed_time = (datetime.datetime.now() - self.start_time).total_seconds() if self.progress == 0: self.progress = 1 estimated_total_time = 100. / self.progress * elapsed_time return datetime.timedelta(seconds = max(estimated_total_time - elapsed_time, 0))
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute parenthesized_expression binary_operator call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier argument_list if_statement comparison_operator attribute identifier identifier integer block expression_statement assignment attribute identifier identifier integer expression_statement assignment identifier binary_operator binary_operator float attribute identifier identifier identifier return_statement call attribute identifier identifier argument_list keyword_argument identifier call identifier argument_list binary_operator identifier identifier integer
estimates the time remaining until script is finished
def prebuild_arch(self, arch): path = self.get_build_dir(arch.arch) if not exists(path): info("creating {}".format(path)) shprint(sh.mkdir, '-p', path)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier if_statement not_operator call identifier argument_list identifier block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call identifier argument_list attribute identifier identifier string string_start string_content string_end identifier
Make the build and target directories
def remove_zone(self, zone_id): updated_zones = [] for zone in self.my_osid_object_form._my_map['zones']: if zone['id'] != zone_id: updated_zones.append(zone) self.my_osid_object_form._my_map['zones'] = updated_zones
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list for_statement identifier subscript attribute attribute identifier identifier identifier string string_start string_content string_end block if_statement comparison_operator subscript identifier string string_start string_content string_end identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment subscript attribute attribute identifier identifier identifier string string_start string_content string_end identifier
remove a zone, given the id
def request(self, method, params): identifier = random.randint(1, 1000) self._transport.write(jsonrpc_request(method, identifier, params)) self._buffer[identifier] = {'flag': asyncio.Event()} yield from self._buffer[identifier]['flag'].wait() result = self._buffer[identifier]['data'] del self._buffer[identifier]['data'] return result
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list integer integer expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list identifier identifier identifier expression_statement assignment subscript attribute identifier identifier identifier dictionary pair string string_start string_content string_end call attribute identifier identifier argument_list expression_statement yield call attribute subscript subscript attribute identifier identifier identifier string string_start string_content string_end identifier argument_list expression_statement assignment identifier subscript subscript attribute identifier identifier identifier string string_start string_content string_end delete_statement subscript subscript attribute identifier identifier identifier string string_start string_content string_end return_statement identifier
Send a JSONRPC request.
def _generate_configs_from_default(self, overrides=None): config = DEFAULT_CONFIG.copy() if not overrides: overrides = {} for k, v in overrides.items(): config[k] = v return config
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement not_operator identifier block expression_statement assignment identifier dictionary for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement assignment subscript identifier identifier identifier return_statement identifier
Generate configs by inheriting from defaults
def decode(self, byteStream): self.header = bytearray(byteStream[:HEADER_SIZE]) self.payload = byteStream[HEADER_SIZE:]
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier call identifier argument_list subscript identifier slice identifier expression_statement assignment attribute identifier identifier subscript identifier slice identifier
Decode the RTP packet.
def rename_tabs_after_change(self, given_name): client = self.get_current_client() repeated = False for cl in self.get_clients(): if id(client) != id(cl) and given_name == cl.given_name: repeated = True break if client.allow_rename and not u'/' in given_name and not repeated: self.rename_client_tab(client, given_name) else: self.rename_client_tab(client, None) if client.allow_rename and not u'/' in given_name and not repeated: for cl in self.get_related_clients(client): self.rename_client_tab(cl, given_name)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier false for_statement identifier call attribute identifier identifier argument_list block if_statement boolean_operator comparison_operator call identifier argument_list identifier call identifier argument_list identifier comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier true break_statement if_statement boolean_operator boolean_operator attribute identifier identifier not_operator comparison_operator string string_start string_content string_end identifier not_operator identifier block expression_statement call attribute identifier identifier argument_list identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier none if_statement boolean_operator boolean_operator attribute identifier identifier not_operator comparison_operator string string_start string_content string_end identifier not_operator identifier block for_statement identifier call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier identifier
Rename tabs after a change in name.
def getSharedReports(self): response = self.request('GET', 'reports.shared').json()['shared']['banners'] reports = [PingdomSharedReport(self, x) for x in response] return reports
module function_definition identifier parameters identifier block expression_statement assignment identifier subscript subscript call attribute call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier list_comprehension call identifier argument_list identifier identifier for_in_clause identifier identifier return_statement identifier
Returns a list of PingdomSharedReport instances
def from_xsc(cls, path): def parse(path): with open(path) as f: lines = f.readlines() NamedXsc = namedtuple('NamedXsc', lines[1].split()[1:]) return NamedXsc(*map(float, lines[2].split())) xsc = parse(path) return u.Quantity([[xsc.a_x, xsc.a_y, xsc.a_z], [xsc.b_x, xsc.b_y, xsc.b_z], [xsc.c_x, xsc.c_y, xsc.c_z]], unit=u.angstroms)
module function_definition identifier parameters identifier identifier block function_definition identifier parameters identifier block with_statement with_clause with_item as_pattern call identifier argument_list identifier as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list string string_start string_content string_end subscript call attribute subscript identifier integer identifier argument_list slice integer return_statement call identifier argument_list list_splat call identifier argument_list identifier call attribute subscript identifier integer identifier argument_list expression_statement assignment identifier call identifier argument_list identifier return_statement call attribute identifier identifier argument_list list list attribute identifier identifier attribute identifier identifier attribute identifier identifier list attribute identifier identifier attribute identifier identifier attribute identifier identifier list attribute identifier identifier attribute identifier identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier
Returns u.Quantity with box vectors from XSC file
def _get_result_paths(self,data): result = {} result['Tree'] = ResultPath(Path=splitext(self._input_filename)[0] + \ '.tree') return result
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list keyword_argument identifier binary_operator subscript call identifier argument_list attribute identifier identifier integer string string_start string_content string_end return_statement identifier
Get the resulting tree
def _domain_event_block_job_cb(conn, domain, disk, job_type, status, opaque): _salt_send_domain_event(opaque, conn, domain, opaque['event'], { 'disk': disk, 'type': _get_libvirt_enum_string('VIR_DOMAIN_BLOCK_JOB_TYPE_', job_type), 'status': _get_libvirt_enum_string('VIR_DOMAIN_BLOCK_JOB_', status) })
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block expression_statement call identifier argument_list identifier identifier identifier subscript identifier string string_start string_content string_end dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end call identifier argument_list string string_start string_content string_end identifier pair string string_start string_content string_end call identifier argument_list string string_start string_content string_end identifier
Domain block job events handler
def jsonload(model, fp): dumped_list = json.load(fp) for link in dumped_list: if len(link) == 2: sid, (s, p, o, a) = link elif len(link) == 4: (s, p, o, a) = link tt = a.get('@target-type') if tt == '@iri-ref': o = I(o) a.pop('@target-type', None) else: continue model.add(s, p, o, a) return
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier for_statement identifier identifier block if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment pattern_list identifier tuple_pattern identifier identifier identifier identifier identifier elif_clause comparison_operator call identifier argument_list identifier integer block expression_statement assignment tuple_pattern identifier identifier identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end none else_clause block continue_statement expression_statement call attribute identifier identifier argument_list identifier identifier identifier identifier return_statement
Load Versa model dumped into JSON form, either raw or canonical
def send_request(self, http_request): self.request_object = http_request self.build_socket() self.build_request() try: self.sock.send(self.request) except socket.error as err: raise errors.TestError( 'We were unable to send the request to the socket', { 'msg': err, 'function': 'http.HttpUA.send_request' }) finally: self.get_response()
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier except_clause as_pattern attribute identifier identifier as_pattern_target identifier block raise_statement call attribute identifier identifier argument_list string string_start string_content string_end dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end string string_start string_content string_end finally_clause block expression_statement call attribute identifier identifier argument_list
Send a request and get response
def sortByIndex(self, index): self.table_level.horizontalHeader().setSortIndicatorShown(True) sort_order = self.table_level.horizontalHeader().sortIndicatorOrder() self.table_index.model().sort(index, sort_order) self._sort_update()
module function_definition identifier parameters identifier identifier block expression_statement call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list true expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list expression_statement call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list
Implement a Index sort.
def end_step(self, lineno, timestamp=None, result_code=None): self.state = self.STATES['step_finished'] step_errors = self.sub_parser.get_artifact() step_error_count = len(step_errors) if step_error_count > settings.PARSER_MAX_STEP_ERROR_LINES: step_errors = step_errors[:settings.PARSER_MAX_STEP_ERROR_LINES] self.artifact["errors_truncated"] = True self.current_step.update({ "finished": timestamp, "finished_linenumber": lineno, "result": self.RESULT_DICT.get(result_code, "unknown"), "errors": step_errors }) self.sub_parser.clear()
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none block expression_statement assignment attribute identifier identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier subscript identifier slice attribute identifier identifier expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end true expression_statement call attribute attribute identifier identifier identifier argument_list dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end pair string string_start string_content string_end identifier expression_statement call attribute attribute identifier identifier identifier argument_list
Fill in the current step's summary and update the state to show the current step has ended.
def _info(self, args, **extra_args): if not isinstance(args, argparse.Namespace): raise logger.error(Exception("args should of an instance of argparse.Namespace")) logger.info("Freight Forwarder: {0}".format(VERSION)) logger.info("docker-py: {0}".format(docker_py_version)) logger.info("Docker Api: {0}".format(DOCKER_API_VERSION)) logger.info("{0} version: {1}".format(platform.python_implementation(), platform.python_version()))
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block if_statement not_operator call identifier argument_list identifier attribute identifier identifier block raise_statement call attribute identifier identifier argument_list call identifier argument_list 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 identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list
Print freight forwarder info to the user.
def get(cls, fpath=None, create_missing=True): "Retrieve the `Config` in `fpath`." fpath = _expand_path(fpath or cls.DEFAULT_CONFIG_PATH) if not fpath.exists() and create_missing: cls.create(fpath) assert fpath.exists(), f'Could not find config at: {fpath}. Please create' with open(fpath, 'r') as yaml_file: return yaml.safe_load(yaml_file)
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier true block expression_statement string string_start string_content string_end expression_statement assignment identifier call identifier argument_list boolean_operator identifier attribute identifier identifier if_statement boolean_operator not_operator call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier assert_statement call attribute identifier identifier argument_list string string_start string_content interpolation identifier string_content string_end with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block return_statement call attribute identifier identifier argument_list identifier
Retrieve the `Config` in `fpath`.
def __prefix_key(self, key): if self.prefix is None: return key if key.startswith(self.prefix + "-"): return key return "{0}-{1}".format(self.prefix, key)
module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier none block return_statement identifier if_statement call attribute identifier identifier argument_list binary_operator attribute identifier identifier string string_start string_content string_end block return_statement identifier return_statement call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier identifier
This will add the prefix to the key if one exists on the store
def _call_watcher(self_, watcher, event): if self_.self_or_cls.param._TRIGGER: pass elif watcher.onlychanged and (not self_._changed(event)): return if self_.self_or_cls.param._BATCH_WATCH: self_._events.append(event) if watcher not in self_._watchers: self_._watchers.append(watcher) elif watcher.mode == 'args': with batch_watch(self_.self_or_cls, run=False): watcher.fn(self_._update_event_type(watcher, event, self_.self_or_cls.param._TRIGGER)) else: with batch_watch(self_.self_or_cls, run=False): event = self_._update_event_type(watcher, event, self_.self_or_cls.param._TRIGGER) watcher.fn(**{event.name: event.new})
module function_definition identifier parameters identifier identifier identifier block if_statement attribute attribute attribute identifier identifier identifier identifier block pass_statement elif_clause boolean_operator attribute identifier identifier parenthesized_expression not_operator call attribute identifier identifier argument_list identifier block return_statement if_statement attribute attribute attribute identifier identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block with_statement with_clause with_item call identifier argument_list attribute identifier identifier keyword_argument identifier false block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier identifier attribute attribute attribute identifier identifier identifier identifier else_clause block with_statement with_clause with_item call identifier argument_list attribute identifier identifier keyword_argument identifier false block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier attribute attribute attribute identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list dictionary_splat dictionary pair attribute identifier identifier attribute identifier identifier
Invoke the given the watcher appropriately given a Event object.
def _handle_github(self): value = click.prompt( _BUG + click.style( '1. Open an issue by typing "open";\n', fg='green', ) + click.style( '2. Print human-readable information by typing ' '"print";\n', fg='yellow', ) + click.style( '3. See the full traceback without submitting details ' '(default: "ignore").\n\n', fg='red', ) + 'Please select an action by typing its name', type=click.Choice([ 'open', 'print', 'ignore', ], ), default='ignore', ) getattr(self, '_process_' + value)()
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator binary_operator binary_operator binary_operator identifier call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end keyword_argument identifier string string_start string_content string_end call attribute identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content escape_sequence string_end keyword_argument identifier string string_start string_content string_end call attribute identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content escape_sequence escape_sequence string_end keyword_argument identifier string string_start string_content string_end string string_start string_content string_end keyword_argument identifier 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 keyword_argument identifier string string_start string_content string_end expression_statement call call identifier argument_list identifier binary_operator string string_start string_content string_end identifier argument_list
Handle exception and submit it as GitHub issue.
def usage(ecode, msg=''): print >> sys.stderr, __doc__ if msg: print >> sys.stderr, msg sys.exit(ecode)
module function_definition identifier parameters identifier default_parameter identifier string string_start string_end block print_statement chevron attribute identifier identifier identifier if_statement identifier block print_statement chevron attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier
Print usage and msg and exit with given code.
def _extract_file(self, tgz, tarinfo, dst_path, buffer_size=10<<20): src = tgz.extractfile(tarinfo) dst = tf_v1.gfile.GFile(dst_path, "wb") while 1: buf = src.read(buffer_size) if not buf: break dst.write(buf) self._log_progress(len(buf)) dst.close() src.close()
module function_definition identifier parameters identifier identifier identifier identifier default_parameter identifier binary_operator integer integer block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end while_statement integer block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement not_operator identifier block break_statement expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list
Extracts 'tarinfo' from 'tgz' and writes to 'dst_path'.
def description(self): if self.release.get('body'): return markdown(self.release['body']) elif self.repository.get('description'): return self.repository['description'] return 'No description provided.'
module function_definition identifier parameters identifier block if_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end block return_statement call identifier argument_list subscript attribute identifier identifier string string_start string_content string_end elif_clause call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end block return_statement subscript attribute identifier identifier string string_start string_content string_end return_statement string string_start string_content string_end
Extract description from a release.
def walk(self, top, topdown=True, onerror=None, **kwargs): try: listing = self.list_status(top, **kwargs) except HdfsException as e: if onerror is not None: onerror(e) return dirnames, filenames = [], [] for f in listing: if f.type == 'DIRECTORY': dirnames.append(f.pathSuffix) elif f.type == 'FILE': filenames.append(f.pathSuffix) else: raise AssertionError("Unexpected type {}".format(f.type)) if topdown: yield top, dirnames, filenames for name in dirnames: new_path = posixpath.join(top, name) for x in self.walk(new_path, topdown, onerror, **kwargs): yield x if not topdown: yield top, dirnames, filenames
module function_definition identifier parameters identifier identifier default_parameter identifier true default_parameter identifier none dictionary_splat_pattern identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier dictionary_splat identifier except_clause as_pattern identifier as_pattern_target identifier block if_statement comparison_operator identifier none block expression_statement call identifier argument_list identifier return_statement expression_statement assignment pattern_list identifier identifier expression_list list list for_statement 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 attribute 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 attribute identifier identifier else_clause block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier if_statement identifier block expression_statement yield expression_list identifier identifier identifier for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier for_statement identifier call attribute identifier identifier argument_list identifier identifier identifier dictionary_splat identifier block expression_statement yield identifier if_statement not_operator identifier block expression_statement yield expression_list identifier identifier identifier
See ``os.walk`` for documentation
def extract_geo(self): altitude = self.extract_altitude() dop = self.extract_dop() lon, lat = self.extract_lon_lat() d = {} if lon is not None and lat is not None: d['latitude'] = lat d['longitude'] = lon if altitude is not None: d['altitude'] = altitude if dop is not None: d['dop'] = dop return d
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list expression_statement assignment identifier dictionary if_statement boolean_operator comparison_operator identifier none comparison_operator identifier none block expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier if_statement comparison_operator identifier none block expression_statement assignment subscript identifier string string_start string_content string_end identifier if_statement comparison_operator identifier none block expression_statement assignment subscript identifier string string_start string_content string_end identifier return_statement identifier
Extract geo-related information from exif
def to_reminders(self, ical, label=None, priority=None, tags=None, tail=None, sep=" ", postdate=None, posttime=None): if not hasattr(ical, 'vevent_list'): return '' reminders = [self.to_remind(vevent, label, priority, tags, tail, sep, postdate, posttime) for vevent in ical.vevent_list] return ''.join(reminders)
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier string string_start string_content string_end default_parameter identifier none default_parameter identifier none block if_statement not_operator call identifier argument_list identifier string string_start string_content string_end block return_statement string string_start string_end expression_statement assignment identifier list_comprehension call attribute identifier identifier argument_list identifier identifier identifier identifier identifier identifier identifier identifier for_in_clause identifier attribute identifier identifier return_statement call attribute string string_start string_end identifier argument_list identifier
Return Remind commands for all events of a iCalendar
def connect(self, mode='default_reset'): print('Connecting...', end='') sys.stdout.flush() last_error = None try: for _ in range(7): last_error = self._connect_attempt(mode=mode, esp32r0_delay=False) if last_error is None: return last_error = self._connect_attempt(mode=mode, esp32r0_delay=True) if last_error is None: return finally: print('') raise FatalError('Failed to connect to %s: %s' % (self.CHIP_NAME, last_error))
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end block expression_statement call identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_end expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier none try_statement block for_statement identifier call identifier argument_list integer block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier false if_statement comparison_operator identifier none block return_statement expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier true if_statement comparison_operator identifier none block return_statement finally_clause block expression_statement call identifier argument_list string string_start string_end raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple attribute identifier identifier identifier
Try connecting repeatedly until successful, or giving up
def _flds_append(flds, addthese, dont_add): for fld in addthese: if fld not in flds and fld not in dont_add: flds.append(fld)
module function_definition identifier parameters identifier identifier identifier block for_statement identifier identifier block if_statement boolean_operator comparison_operator identifier identifier comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier
Retain order of fields as we add them once to the list.
def auth(username, password): _info = __get_connection_info() if _info is None: return False try: conn = MySQLdb.connect(_info['hostname'], _info['username'], _info['password'], _info['database']) except OperationalError as e: log.error(e) return False cur = conn.cursor() cur.execute(_info['auth_sql'].format(username, password)) if cur.rowcount == 1: return True return False
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list if_statement comparison_operator identifier none block return_statement false try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement false expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list call attribute subscript identifier string string_start string_content string_end identifier argument_list identifier identifier if_statement comparison_operator attribute identifier identifier integer block return_statement true return_statement false
Authenticate using a MySQL user table
def visit_assignname(self, node, parent, node_name=None): newnode = nodes.AssignName( node_name, getattr(node, "lineno", None), getattr(node, "col_offset", None), parent, ) self._save_assignment(newnode) return newnode
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list 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 expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
visit a node and return a AssignName node
def process(self): assert self.queue is not None while True: event = self.queue.get() if self.pre_process_event(event): self.invoke_handlers(event) self.queue.task_done()
module function_definition identifier parameters identifier block assert_statement comparison_operator attribute identifier identifier none while_statement true block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list if_statement call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list
Loops over the underlying queue of events and processes them in order.
def _run_command(self, packet): create_temp_cli = self.client_states is None if create_temp_cli: pane_id = int(packet['pane_id']) self._create_app() with set_app(self.client_state.app): self.pymux.arrangement.set_active_window_from_pane_id(pane_id) with set_app(self.client_state.app): try: self.pymux.handle_command(packet['data']) finally: self._close_connection()
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier comparison_operator attribute identifier identifier none if_statement identifier block expression_statement assignment identifier call identifier argument_list subscript identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list with_statement with_clause with_item call identifier argument_list attribute attribute identifier identifier identifier block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier with_statement with_clause with_item call identifier argument_list attribute attribute identifier identifier identifier block try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list subscript identifier string string_start string_content string_end finally_clause block expression_statement call attribute identifier identifier argument_list
Execute a run command from the client.
def search(self, keyword, children=None, arg=None): if children is None: children = self.substmts return [ ch for ch in children if (ch.keyword == keyword and (arg is None or ch.arg == arg))]
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier attribute identifier identifier return_statement list_comprehension identifier for_in_clause identifier identifier if_clause parenthesized_expression boolean_operator comparison_operator attribute identifier identifier identifier parenthesized_expression boolean_operator comparison_operator identifier none comparison_operator attribute identifier identifier identifier
Return list of receiver's substmts with `keyword`.
def fetch_all(self, R, depth=1, **kwargs): "Request multiple objects from API" d, e = self._fetcher.fetch_all(R, depth, kwargs) if e: raise e return d
module function_definition identifier parameters identifier identifier default_parameter identifier integer dictionary_splat_pattern identifier block expression_statement string string_start string_content string_end expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list identifier identifier identifier if_statement identifier block raise_statement identifier return_statement identifier
Request multiple objects from API
def enb64_app(parser, cmd, args): parser.add_argument('value', help='the value to base64 encode, read from stdin if omitted', nargs='?') args = parser.parse_args(args) return enb64(pwnypack.main.binary_value_or_stdin(args.value))
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement call identifier argument_list call attribute attribute identifier identifier identifier argument_list attribute identifier identifier
base64 encode a value.
def open(self): if self.protocol==0: _in = open(self.name) else: _in = open(self.name,'rb') self.fields = cPickle.load(_in) self.next_id = cPickle.load(_in) self.records = cPickle.load(_in) self.indices = cPickle.load(_in) for f in self.indices.keys(): setattr(self,'_'+f,Index(self,f)) _in.close() self.mode = "open" return self
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier integer block expression_statement assignment identifier call identifier argument_list attribute identifier identifier else_clause block expression_statement assignment identifier call identifier argument_list attribute identifier identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier for_statement identifier call attribute attribute identifier identifier identifier argument_list block expression_statement call identifier argument_list identifier binary_operator string string_start string_content string_end identifier call identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier string string_start string_content string_end return_statement identifier
Open an existing database and load its content into memory
def init_sentry(self,): if not self.use_sentry: return sentry_config = self.keychain.get_service("sentry") tags = { "repo": self.repo_name, "branch": self.repo_branch, "commit": self.repo_commit, "cci version": cumulusci.__version__, } tags.update(self.config.get("sentry_tags", {})) env = self.config.get("sentry_environment", "CumulusCI CLI") self.sentry = raven.Client( dsn=sentry_config.dsn, environment=env, tags=tags, processors=("raven.processors.SanitizePasswordsProcessor",), )
module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block return_statement expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier expression_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end dictionary expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier tuple string string_start string_content string_end
Initializes sentry.io error logging for this session
def roll(rest, nick): "Roll a die, default = 100." if rest: rest = rest.strip() die = int(rest) else: die = 100 myroll = random.randint(1, die) return "%s rolls %s" % (nick, myroll)
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list identifier else_clause block expression_statement assignment identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list integer identifier return_statement binary_operator string string_start string_content string_end tuple identifier identifier
Roll a die, default = 100.
def launch_ssh(self, name, port): if options.user: name = '%s@%s' % (options.user, name) evaluated = options.ssh % {'host': name, 'port': port} if evaluated == options.ssh: evaluated = '%s %s' % (evaluated, name) os.execlp('/bin/sh', 'sh', '-c', evaluated)
module function_definition identifier parameters identifier identifier identifier block if_statement attribute identifier identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple attribute identifier identifier identifier expression_statement assignment identifier binary_operator attribute identifier identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier
Launch the ssh command in the child process
def _set_token(self): try: self.token = os.environ['CERBERUS_TOKEN'] if self.verbose: print("Overriding Cerberus token with environment variable.", file=sys.stderr) logger.info("Overriding Cerberus token with environment variable.") return except: pass if self.username: ua = UserAuth(self.cerberus_url, self.username, self.password) self.token = ua.get_token() else: awsa = AWSAuth(self.cerberus_url, region=self.region, aws_session=self.aws_session, verbose=self.verbose) self.token = awsa.get_token()
module function_definition identifier parameters identifier block try_statement block expression_statement assignment attribute identifier identifier subscript attribute identifier identifier string string_start string_content string_end if_statement attribute identifier identifier block expression_statement call identifier argument_list string string_start string_content string_end keyword_argument identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement except_clause block pass_statement if_statement attribute identifier identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list else_clause block expression_statement assignment identifier call identifier argument_list attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list
Set the Cerberus token based on auth type
def metadata_sorter(x, y): if x == y: return 0 if x in METADATA_SORTER_FIRST and y in METADATA_SORTER_FIRST: return -1 if METADATA_SORTER_FIRST.index(x) < METADATA_SORTER_FIRST.index(y) else 1 elif x in METADATA_SORTER_FIRST: return -1 elif y in METADATA_SORTER_FIRST: return 1 else: if x.startswith('_') and y.startswith('_'): return cmp(x[1:], y[1:]) elif x.startswith('_'): return 1 elif y.startswith('_'): return -1 else: return cmp(x, y)
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier identifier block return_statement integer if_statement boolean_operator comparison_operator identifier identifier comparison_operator identifier identifier block return_statement conditional_expression unary_operator integer comparison_operator call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier integer elif_clause comparison_operator identifier identifier block return_statement unary_operator integer elif_clause comparison_operator identifier identifier block return_statement integer else_clause block if_statement boolean_operator call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end block return_statement call identifier argument_list subscript identifier slice integer subscript identifier slice integer elif_clause call attribute identifier identifier argument_list string string_start string_content string_end block return_statement integer elif_clause call attribute identifier identifier argument_list string string_start string_content string_end block return_statement unary_operator integer else_clause block return_statement call identifier argument_list identifier identifier
Sort metadata keys by priority.
async def get_source_list(self, scheme: str = "") -> List[Source]: res = await self.services["avContent"]["getSourceList"](scheme=scheme) return [Source.make(**x) for x in res]
module function_definition identifier parameters identifier typed_default_parameter identifier type identifier string string_start string_end type generic_type identifier type_parameter type identifier block expression_statement assignment identifier await call subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end argument_list keyword_argument identifier identifier return_statement list_comprehension call attribute identifier identifier argument_list dictionary_splat identifier for_in_clause identifier identifier
Return available sources for playback.
def information(filename): check_if_this_file_exist(filename) filename = os.path.abspath(filename) result = get_json(filename) result = result[0] return result
module function_definition identifier parameters identifier block expression_statement call identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier subscript identifier integer return_statement identifier
Returns the file exif
def _send_flow(self, active): args = Writer() args.write_bit(active) self.send_frame(MethodFrame(self.channel_id, 20, 20, args)) self.channel.add_synchronous_cb(self._recv_flow_ok)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list attribute identifier identifier integer integer identifier expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier
Send a flow control command.
def iter_transport_opts(opts): transports = set() for transport, opts_overrides in six.iteritems(opts.get('transport_opts', {})): t_opts = dict(opts) t_opts.update(opts_overrides) t_opts['transport'] = transport transports.add(transport) yield transport, t_opts if opts['transport'] not in transports: yield opts['transport'], opts
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list for_statement pattern_list identifier identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end dictionary block expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement yield expression_list identifier identifier if_statement comparison_operator subscript identifier string string_start string_content string_end identifier block expression_statement yield expression_list subscript identifier string string_start string_content string_end identifier
Yield transport, opts for all master configured transports
def grep_file(query, item): return ['%s: %s' % (item, line) for line in open(item) if re.search(query, line)]
module function_definition identifier parameters identifier identifier block return_statement list_comprehension binary_operator string string_start string_content string_end tuple identifier identifier for_in_clause identifier call identifier argument_list identifier if_clause call attribute identifier identifier argument_list identifier identifier
This function performs the actual grep on a given file.
def _create_info_struct(file, mode, samplerate, channels, format, subtype, endian): original_format = format if format is None: format = _get_format_from_filename(file, mode) assert isinstance(format, (_unicode, str)) else: _check_format(format) info = _ffi.new("SF_INFO*") if 'r' not in mode or format.upper() == 'RAW': if samplerate is None: raise TypeError("samplerate must be specified") info.samplerate = samplerate if channels is None: raise TypeError("channels must be specified") info.channels = channels info.format = _format_int(format, subtype, endian) else: if any(arg is not None for arg in ( samplerate, channels, original_format, subtype, endian)): raise TypeError("Not allowed for existing files (except 'RAW'): " "samplerate, channels, format, subtype, endian") return info
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier identifier block expression_statement assignment identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list identifier identifier assert_statement call identifier argument_list identifier tuple identifier identifier else_clause block expression_statement call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement boolean_operator comparison_operator string string_start string_content string_end identifier comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end block if_statement comparison_operator identifier none block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier identifier if_statement comparison_operator identifier none block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list identifier identifier identifier else_clause block if_statement call identifier generator_expression comparison_operator identifier none for_in_clause identifier tuple identifier identifier identifier 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 return_statement identifier
Check arguments and create SF_INFO struct.
def event_table(events): table = formatting.Table([ "Id", "Start Date", "End Date", "Subject", "Status", "Acknowledged", "Updates", "Impacted Resources" ], title="Upcoming Events") table.align['Subject'] = 'l' table.align['Impacted Resources'] = 'l' for event in events: table.add_row([ event.get('id'), utils.clean_time(event.get('startDate')), utils.clean_time(event.get('endDate')), utils.clean_splitlines(event.get('subject')), utils.lookup(event, 'statusCode', 'name'), event.get('acknowledgedFlag'), event.get('updateCount'), event.get('impactedResourceCount') ]) return table
module function_definition identifier parameters identifier block expression_statement assignment identifier 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 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 keyword_argument identifier string string_start string_content string_end expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list list call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list identifier string string_start string_content string_end string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end return_statement identifier
Formats a table for events
def alter_targets(self): if self.is_derived(): return [], None return self.fs.variant_dir_target_climb(self, self.dir, [self.name])
module function_definition identifier parameters identifier block if_statement call attribute identifier identifier argument_list block return_statement expression_list list none return_statement call attribute attribute identifier identifier identifier argument_list identifier attribute identifier identifier list attribute identifier identifier
Return any corresponding targets in a variant directory.
def insert_tree(self, items, node, headers): first = items[0] child = node.get_child(first) if child is not None: child.count += 1 else: child = node.add_child(first) if headers[first] is None: headers[first] = child else: current = headers[first] while current.link is not None: current = current.link current.link = child remaining_items = items[1:] if len(remaining_items) > 0: self.insert_tree(remaining_items, child, headers)
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier subscript identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement augmented_assignment attribute identifier identifier integer else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator subscript identifier identifier none block expression_statement assignment subscript identifier identifier identifier else_clause block expression_statement assignment identifier subscript identifier identifier while_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier attribute identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment identifier subscript identifier slice integer if_statement comparison_operator call identifier argument_list identifier integer block expression_statement call attribute identifier identifier argument_list identifier identifier identifier
Recursively grow FP tree.
def _parse_qualimap_coverage(table): out = {} for row in table.find_all("tr"): col, val = [x.text for x in row.find_all("td")] if col == "Mean": out["Coverage (Mean)"] = val return out
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary for_statement identifier call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment pattern_list identifier identifier list_comprehension attribute identifier identifier for_in_clause identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment subscript identifier string string_start string_content string_end identifier return_statement identifier
Parse summary qualimap coverage metrics.
def gatk_indel_realignment_cl(runner, align_bam, ref_file, intervals, tmp_dir, region=None, deep_coverage=False, known_vrns=None): if not known_vrns: known_vrns = {} params = ["-T", "IndelRealigner", "-I", align_bam, "-R", ref_file, "-targetIntervals", intervals, ] if region: params += ["-L", region] if known_vrns.get("train_indels"): params += ["--knownAlleles", known_vrns["train_indels"]] if deep_coverage: params += ["--maxReadsInMemory", "300000", "--maxReadsForRealignment", str(int(5e5)), "--maxReadsForConsensuses", "500", "--maxConsensuses", "100"] return runner.cl_gatk(params, tmp_dir)
module function_definition identifier parameters identifier identifier identifier identifier identifier default_parameter identifier none default_parameter identifier false default_parameter identifier none block if_statement not_operator identifier block expression_statement assignment identifier dictionary 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 identifier string string_start string_content string_end identifier string string_start string_content string_end identifier if_statement identifier block expression_statement augmented_assignment identifier list string string_start string_content string_end identifier if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement augmented_assignment identifier list string string_start string_content string_end subscript identifier string string_start string_content string_end if_statement identifier block expression_statement augmented_assignment identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end call identifier argument_list call identifier argument_list float string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end return_statement call attribute identifier identifier argument_list identifier identifier
Prepare input arguments for GATK indel realignment.
def initauth(self): headers = {'User-agent': 'CLAMClientAPI-' + clam.common.data.VERSION} if self.oauth: if not self.oauth_access_token: r = requests.get(self.url,headers=headers, verify=self.verify) if r.status_code == 404: raise clam.common.data.NotFound("Authorization provider not found") elif r.status_code == 403: raise clam.common.data.PermissionDenied("Authorization provider denies access") elif not (r.status_code >= 200 and r.status_code <= 299): raise Exception("An error occured, return code " + str(r.status_code)) data = self._parse(r.text) if data is True: raise Exception("No access token provided, but Authorization Provider requires manual user input. Unable to authenticate automatically. Obtain an access token from " + r.geturl()) else: self.oauth_access_token = data.oauth_access_token headers['Authorization'] = 'Bearer ' + self.oauth_access_token return headers
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end binary_operator string string_start string_content string_end attribute attribute attribute identifier identifier identifier identifier if_statement attribute identifier identifier block if_statement not_operator attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier if_statement comparison_operator attribute identifier identifier integer block raise_statement call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end elif_clause comparison_operator attribute identifier identifier integer block raise_statement call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end elif_clause not_operator parenthesized_expression boolean_operator comparison_operator attribute identifier identifier integer comparison_operator attribute identifier identifier integer block raise_statement call identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier if_statement comparison_operator identifier true block raise_statement call identifier argument_list binary_operator string string_start string_content string_end call attribute identifier identifier argument_list else_clause block expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end binary_operator string string_start string_content string_end attribute identifier identifier return_statement identifier
Initialise authentication, for internal use
def remove_namespaces(self, rpc_reply): self.__xslt=self.__transform_reply self.__parser = etree.XMLParser(remove_blank_text=True) self.__xslt_doc = etree.parse(io.BytesIO(self.__xslt), self.__parser) self.__transform = etree.XSLT(self.__xslt_doc) self.__root = etree.fromstring(str(self.__transform(etree.parse(StringIO(str(rpc_reply)))))) return self.__root
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list keyword_argument identifier true expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list call identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list call identifier argument_list call identifier argument_list identifier return_statement attribute identifier identifier
remove xmlns attributes from rpc reply
def init_from_datastore(self): self._data = {} client = self._datastore_client for entity in client.query_fetch(kind=KIND_CLASSIFICATION_BATCH): class_batch_id = entity.key.flat_path[-1] self.data[class_batch_id] = dict(entity)
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier dictionary expression_statement assignment identifier attribute identifier identifier for_statement identifier call attribute identifier identifier argument_list keyword_argument identifier identifier block expression_statement assignment identifier subscript attribute attribute identifier identifier identifier unary_operator integer expression_statement assignment subscript attribute identifier identifier identifier call identifier argument_list identifier
Initializes data by reading it from the datastore.
def RNN_step(weights, gates): def rnn_step_fwd(prevstate_inputs, drop=0.0): prevstate, inputs = prevstate_inputs cell_tm1, hidden_tm1 = prevstate acts, bp_acts = weights.begin_update((inputs, hidden_tm1), drop=drop) (cells, hiddens), bp_gates = gates.begin_update((acts, cell_tm1), drop=drop) def rnn_step_bwd(d_state_d_hiddens, sgd=None): (d_cells, d_hiddens), d_hiddens = d_state_d_hiddens d_acts, d_cell_tm1 = bp_gates((d_cells, d_hiddens), sgd=sgd) d_inputs, d_hidden_tm1 = bp_acts(d_acts, sgd=sgd) return (d_cell_tm1, d_hidden_tm1), d_inputs return ((cells, hiddens), hiddens), rnn_step_bwd model = wrap(rnn_step_fwd, weights, gates) model.nO = weights.nO model.nI = weights.nI model.weights = weights model.gates = gates return model
module function_definition identifier parameters identifier identifier block function_definition identifier parameters identifier default_parameter identifier float block expression_statement assignment pattern_list identifier identifier identifier expression_statement assignment pattern_list identifier identifier identifier expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list tuple identifier identifier keyword_argument identifier identifier expression_statement assignment pattern_list tuple_pattern identifier identifier identifier call attribute identifier identifier argument_list tuple identifier identifier keyword_argument identifier identifier function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment pattern_list tuple_pattern identifier identifier identifier identifier expression_statement assignment pattern_list identifier identifier call identifier argument_list tuple identifier identifier keyword_argument identifier identifier expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier keyword_argument identifier identifier return_statement expression_list tuple identifier identifier identifier return_statement expression_list tuple tuple identifier identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier return_statement identifier
Create a step model for an RNN, given weights and gates functions.
def getCurrentFadeColor(self, bBackground): fn = self.function_table.getCurrentFadeColor result = fn(bBackground) return result
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier return_statement identifier
Get current fade color value.
def _flush(self): self._buffer.sort() self._replace_batch() self._buffer = [] self._compress()
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier list expression_statement call attribute identifier identifier argument_list
Purges the buffer and commits all pending values into the estimator.
def error(self, i: int=None) -> str: head = "[" + colors.red("error") + "]" if i is not None: head = str(i) + " " + head return head
module function_definition identifier parameters identifier typed_default_parameter identifier type identifier none type identifier block expression_statement assignment identifier binary_operator 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 if_statement comparison_operator identifier none block expression_statement assignment identifier binary_operator binary_operator call identifier argument_list identifier string string_start string_content string_end identifier return_statement identifier
Returns an error message
def _buildExecutor(self): info = addict.Dict() info.name = "toil" info.command.value = resolveEntryPoint('_toil_mesos_executor') info.executor_id.value = "toil-%i" % os.getpid() info.source = pwd.getpwuid(os.getuid()).pw_name return info
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier string string_start string_content string_end expression_statement assignment attribute attribute identifier identifier identifier call identifier argument_list string string_start string_content string_end expression_statement assignment attribute attribute identifier identifier identifier binary_operator string string_start string_content string_end call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier attribute call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier return_statement identifier
Creates and returns an ExecutorInfo-shaped object representing our executor implementation.
def register(self, cls, instance): if not issubclass(cls, DropletInterface): raise TypeError('Given class is not a NAZInterface subclass: %s' % cls) if not isinstance(instance, cls): raise TypeError('Given instance does not implement the class: %s' % instance) if instance.name in self.INSTANCES_BY_NAME: if self.INSTANCES_BY_NAME[instance.name] != instance: raise ValueError('Given name is registered ' 'by other instance: %s' % instance.name) self.INSTANCES_BY_INTERFACE[cls].add(instance) self.INSTANCES_BY_NAME[instance.name] = instance
module function_definition identifier parameters identifier identifier identifier block if_statement not_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier if_statement not_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier if_statement comparison_operator attribute identifier identifier attribute identifier identifier block if_statement comparison_operator subscript attribute identifier identifier attribute identifier identifier identifier block raise_statement call identifier argument_list binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end attribute identifier identifier expression_statement call attribute subscript attribute identifier identifier identifier identifier argument_list identifier expression_statement assignment subscript attribute identifier identifier attribute identifier identifier identifier
Register the given instance as implementation for a class interface
def _limit_call_handler(self): with self.limit_lock: if self.limit_per_min <= 0: return now = time.time() self.limits = [l for l in self.limits if l > now] self.limits.append(now + 60) if len(self.limits) >= self.limit_per_min: time.sleep(self.limits[0] - now)
module function_definition identifier parameters identifier block with_statement with_clause with_item attribute identifier identifier block if_statement comparison_operator attribute identifier identifier integer block return_statement expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier list_comprehension identifier for_in_clause identifier attribute identifier identifier if_clause comparison_operator identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator identifier integer if_statement comparison_operator call identifier argument_list attribute identifier identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator subscript attribute identifier identifier integer identifier
Ensure we don't exceed the N requests a minute limit by leveraging a thread lock
def _notify_remove_at(self, index, length=1): slice_ = self._slice_at(index, length) self._notify_remove(slice_)
module function_definition identifier parameters identifier identifier default_parameter identifier integer block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list identifier
Notify about an RemoveChange at a caertain index and length.
def digest_packets(packets, hasher): data_to_hash = io.BytesIO() for p in packets: data_to_hash.write(p['_to_hash']) hasher.update(data_to_hash.getvalue()) return hasher.digest()
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list return_statement call attribute identifier identifier argument_list
Compute digest on specified packets, according to '_to_hash' field.
def re_run_file(self): if self.get_option('save_all_before_run'): self.save_all() if self.__last_ec_exec is None: return (fname, wdir, args, interact, debug, python, python_args, current, systerm, post_mortem, clear_namespace) = self.__last_ec_exec if not systerm: self.run_in_current_ipyclient.emit(fname, wdir, args, debug, post_mortem, current, clear_namespace) else: self.main.open_external_console(fname, wdir, args, interact, debug, python, python_args, systerm, post_mortem)
module function_definition identifier parameters identifier block if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list if_statement comparison_operator attribute identifier identifier none block return_statement expression_statement assignment tuple_pattern identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier attribute identifier identifier if_statement not_operator identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier identifier identifier identifier identifier identifier else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier identifier identifier identifier identifier identifier identifier identifier
Re-run last script
def step(self): current_state = max(self.infos(type=State), key=attrgetter('creation_time')) current_contents = float(current_state.contents) new_contents = 1 - current_contents info_out = State(origin=self, contents=new_contents) transformations.Mutation(info_in=current_state, info_out=info_out)
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier binary_operator integer identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier
Prompt the environment to change.