code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def process_response(self, request, response): if COOKIE_KEY not in request.COOKIES: response.set_cookie(COOKIE_KEY, COOKIE_PASS, httponly=True, expires=datetime.now()+timedelta(days=30)) if DJANGOSPAM_LOG: logger.log("PASS RESPONSE", request.method, request.path_info, request.META.get("HTTP_USER_AGENT", "undefined")) return response
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier keyword_argument identifier true keyword_argument identifier binary_operator call attribute identifier identifier argument_list call identifier argument_list keyword_argument identifier integer if_statement identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier attribute identifier identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end return_statement identifier
Sets "Ok" cookie on unknown users.
def _handle_response(self, response): status = response.status_code if status == 400: msg = u"bad request" raise exceptions.BadRequest(status, msg) elif status == 401: msg = u"authorization failed user:%s" % (self.sk_user) raise exceptions.Unauthorized(status, msg) elif status == 404: raise exceptions.NotFound() elif status == 422: msg = u"bad request" raise exceptions.BadRequest(status, msg) elif status in range(400, 500): msg = u"unexpected bad request" raise exceptions.BadRequest(status, msg) elif status in range(500, 600): raise exceptions.ServerError() return response
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier integer block expression_statement assignment identifier string string_start string_content string_end raise_statement call attribute identifier identifier argument_list identifier identifier elif_clause comparison_operator identifier integer block expression_statement assignment identifier binary_operator string string_start string_content string_end parenthesized_expression attribute identifier identifier raise_statement call attribute identifier identifier argument_list identifier identifier elif_clause comparison_operator identifier integer block raise_statement call attribute identifier identifier argument_list elif_clause comparison_operator identifier integer block expression_statement assignment identifier string string_start string_content string_end raise_statement call attribute identifier identifier argument_list identifier identifier elif_clause comparison_operator identifier call identifier argument_list integer integer block expression_statement assignment identifier string string_start string_content string_end raise_statement call attribute identifier identifier argument_list identifier identifier elif_clause comparison_operator identifier call identifier argument_list integer integer block raise_statement call attribute identifier identifier argument_list return_statement identifier
internal method to throw the correct exception if something went wrong
def _get_parallel_regions(data): callable_regions = tz.get_in(["config", "algorithm", "callable_regions"], data) if not callable_regions: raise ValueError("Did not find any callable regions for sample: %s\n" "Check 'align/%s/*-callableblocks.bed' and 'regions' to examine callable regions" % (dd.get_sample_name(data), dd.get_sample_name(data))) with open(callable_regions) as in_handle: regions = [(xs[0], int(xs[1]), int(xs[2])) for xs in (l.rstrip().split("\t") for l in in_handle) if (len(xs) >= 3 and not xs[0].startswith(("track", "browser",)))] return regions
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 identifier if_statement not_operator identifier block raise_statement call identifier argument_list binary_operator concatenated_string string string_start string_content escape_sequence string_end string string_start string_content string_end tuple call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier with_statement with_clause with_item as_pattern call identifier argument_list identifier as_pattern_target identifier block expression_statement assignment identifier list_comprehension tuple subscript identifier integer call identifier argument_list subscript identifier integer call identifier argument_list subscript identifier integer for_in_clause identifier generator_expression call attribute call attribute identifier identifier argument_list identifier argument_list string string_start string_content escape_sequence string_end for_in_clause identifier identifier if_clause parenthesized_expression boolean_operator comparison_operator call identifier argument_list identifier integer not_operator call attribute subscript identifier integer identifier argument_list tuple string string_start string_content string_end string string_start string_content string_end return_statement identifier
Retrieve regions to run in parallel, putting longest intervals first.
def _column_reduction(self): i1, j = np.unique(np.argmin(self.c, axis=0), return_index=True) self._x[i1] = j if len(i1) == self.n: return False self._y[j] = i1 self._v = np.min(self.c, axis=0) tempc = self.c.copy() tempc[i1, j] = np.inf mu = np.min(tempc[i1, :] - self._v[None, :], axis=1) self._v[j] -= mu return True
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier integer keyword_argument identifier true expression_statement assignment subscript attribute identifier identifier identifier identifier if_statement comparison_operator call identifier argument_list identifier attribute identifier identifier block return_statement false expression_statement assignment subscript attribute identifier identifier identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier integer expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment subscript identifier identifier identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator subscript identifier identifier slice subscript attribute identifier identifier none slice keyword_argument identifier integer expression_statement augmented_assignment subscript attribute identifier identifier identifier identifier return_statement true
Column reduction and reduction transfer steps from LAPJV algorithm
def create_bottleneck_file(bottleneck_path, image_lists, label_name, index, image_dir, category, sess, jpeg_data_tensor, decoded_image_tensor, resized_input_tensor, bottleneck_tensor): tf.logging.debug('Creating bottleneck at ' + bottleneck_path) image_path = get_image_path(image_lists, label_name, index, image_dir, category) if not tf.gfile.Exists(image_path): tf.logging.fatal('File does not exist %s', image_path) image_data = tf.gfile.GFile(image_path, 'rb').read() try: bottleneck_values = run_bottleneck_on_image( sess, image_data, jpeg_data_tensor, decoded_image_tensor, resized_input_tensor, bottleneck_tensor) except Exception as e: raise RuntimeError('Error during processing file %s (%s)' % (image_path, str(e))) bottleneck_string = ','.join(str(x) for x in bottleneck_values) with open(bottleneck_path, 'w') as bottleneck_file: bottleneck_file.write(bottleneck_string)
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list identifier identifier identifier identifier identifier if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end identifier argument_list try_statement block expression_statement assignment identifier call identifier argument_list identifier identifier identifier identifier identifier identifier except_clause as_pattern identifier as_pattern_target identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier call identifier argument_list identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier generator_expression call identifier argument_list identifier for_in_clause identifier identifier with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier
Create a single bottleneck file.
def mnist(training): if training: data_filename = 'train-images-idx3-ubyte.gz' labels_filename = 'train-labels-idx1-ubyte.gz' count = 60000 else: data_filename = 't10k-images-idx3-ubyte.gz' labels_filename = 't10k-labels-idx1-ubyte.gz' count = 10000 data_filename = maybe_download(MNIST_URL, data_filename) labels_filename = maybe_download(MNIST_URL, labels_filename) return (mnist_extract_data(data_filename, count), mnist_extract_labels(labels_filename, count))
module function_definition identifier parameters identifier block if_statement identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier integer else_clause block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier integer expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier return_statement tuple call identifier argument_list identifier identifier call identifier argument_list identifier identifier
Downloads MNIST and loads it into numpy arrays.
def destroy(self, request, pk=None): org = self.get_object() org.archived = True org.save() return Response(status=status.HTTP_204_NO_CONTENT)
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier true expression_statement call attribute identifier identifier argument_list return_statement call identifier argument_list keyword_argument identifier attribute identifier identifier
For DELETE actions, archive the organization, don't delete.
def open_file(self, fname, length=None, offset=None, swap=None, block=None, peek=None): if length is None: length = self.length if offset is None: offset = self.offset if swap is None: swap = self.swap_size return binwalk.core.common.BlockFile(fname, subclass=self.subclass, length=length, offset=offset, swap=swap, block=block, peek=peek)
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 none block if_statement comparison_operator identifier none block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier attribute identifier identifier return_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
Opens the specified file with all pertinent configuration settings.
def load (filename, simConfig=None, output=False, instantiate=True, createNEURONObj=True): from .. import sim sim.initialize() sim.cfg.createNEURONObj = createNEURONObj sim.loadAll(filename, instantiate=instantiate, createNEURONObj=createNEURONObj) if simConfig: sim.setSimCfg(simConfig) if len(sim.net.cells) == 0 and instantiate: pops = sim.net.createPops() cells = sim.net.createCells() conns = sim.net.connectCells() stims = sim.net.addStims() rxd = sim.net.addRxD() simData = sim.setupRecording() if output: try: return (pops, cells, conns, stims, rxd, simData) except: pass
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier false default_parameter identifier true default_parameter identifier true block import_from_statement relative_import import_prefix dotted_name identifier expression_statement call attribute identifier identifier argument_list expression_statement assignment attribute attribute identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier if_statement boolean_operator comparison_operator call identifier argument_list attribute attribute identifier identifier identifier integer identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list if_statement identifier block try_statement block return_statement tuple identifier identifier identifier identifier identifier identifier except_clause block pass_statement
Sequence of commands load, simulate and analyse network
def alloc_vpcid(nexus_ips): LOG.debug("alloc_vpc() called") vpc_id = 0 intersect = _get_free_vpcids_on_switches(nexus_ips) for intersect_tuple in intersect: try: update_vpc_entry(nexus_ips, intersect_tuple.vpc_id, False, True) vpc_id = intersect_tuple.vpc_id break except Exception: LOG.exception( "This exception is expected if another controller " "beat us to vpcid %(vpcid)s for nexus %(ip)s", {'vpcid': intersect_tuple.vpc_id, 'ip': ', '.join(map(str, nexus_ips))}) return vpc_id
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier integer expression_statement assignment identifier call identifier argument_list identifier for_statement identifier identifier block try_statement block expression_statement call identifier argument_list identifier attribute identifier identifier false true expression_statement assignment identifier attribute identifier identifier break_statement except_clause 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 dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier identifier return_statement identifier
Allocate a vpc id for the given list of switch_ips.
def send(self, commands): "Ship commands to the daemon." if not commands.endswith("\n"): commands += "\n" self.sock.send(commands)
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end if_statement not_operator call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end block expression_statement augmented_assignment identifier string string_start string_content escape_sequence string_end expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Ship commands to the daemon.
def unquote_string(code): scode = code.strip() assert scode[-1] in ["'", '"'] assert scode[0] in ["'", '"'] or scode[1] in ["'", '"'] return ast.literal_eval(scode)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list assert_statement comparison_operator subscript identifier unary_operator integer list string string_start string_content string_end string string_start string_content string_end assert_statement boolean_operator comparison_operator subscript identifier integer list string string_start string_content string_end string string_start string_content string_end comparison_operator subscript identifier integer list string string_start string_content string_end string string_start string_content string_end return_statement call attribute identifier identifier argument_list identifier
Returns a string from code that contains a repr of the string
def _update(self): initial_time = time.time() self._updateHiddenStateTrajectories() self._updateEmissionProbabilities() self._updateTransitionMatrix() final_time = time.time() elapsed_time = final_time - initial_time logger().info("BHMM update iteration took %.3f s" % elapsed_time)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier binary_operator identifier identifier expression_statement call attribute call identifier argument_list identifier argument_list binary_operator string string_start string_content string_end identifier
Update the current model using one round of Gibbs sampling.
def column(self, key): for row in self.rows: if key in row: yield row[key]
module function_definition identifier parameters identifier identifier block for_statement identifier attribute identifier identifier block if_statement comparison_operator identifier identifier block expression_statement yield subscript identifier identifier
Iterator over a given column, skipping steps that don't have that key
def getKnownLadders(reset=False): if not ladderCache or reset: jsonFiles = os.path.join(c.LADDER_FOLDER, "*.json") for ladderFilepath in glob.glob(jsonFiles): filename = os.path.basename(ladderFilepath) name = re.search("^ladder_(.*?).json$", filename).groups()[0] ladder = Ladder(name) ladderCache[ladder.name] = ladder return ladderCache
module function_definition identifier parameters default_parameter identifier false block if_statement boolean_operator not_operator identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier string string_start string_content string_end for_statement identifier call attribute identifier identifier argument_list identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier subscript call attribute call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier argument_list integer expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment subscript identifier attribute identifier identifier identifier return_statement identifier
identify all of the currently defined ladders
def _iris_obj_to_attrs(obj): attrs = {'standard_name': obj.standard_name, 'long_name': obj.long_name} if obj.units.calendar: attrs['calendar'] = obj.units.calendar if obj.units.origin != '1' and not obj.units.is_unknown(): attrs['units'] = obj.units.origin attrs.update(obj.attributes) return dict((k, v) for k, v in attrs.items() if v is not None)
module function_definition identifier parameters identifier block 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 if_statement attribute attribute identifier identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end attribute attribute identifier identifier identifier if_statement boolean_operator comparison_operator attribute attribute identifier identifier identifier string string_start string_content string_end not_operator call attribute attribute identifier identifier identifier argument_list block expression_statement assignment subscript identifier string string_start string_content string_end attribute attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier return_statement call identifier generator_expression tuple identifier identifier for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list if_clause comparison_operator identifier none
Return a dictionary of attrs when given a Iris object
def build_base_image_cmd(self, force): check_permissions() basetag = self.conf.basetag basedir = self.conf.basedir verbose = self.conf.verbose if self.image_exists(tag=basetag): if not force: echo("Image with tag '{0}' already exists".format(basetag)) return self.image_by_tag(basetag) else: self.remove_image(basetag) echo("Building base image") stream = self.build(path=basedir, rm=True, tag=basetag) err = self.__handle_build_stream(stream, verbose) if err: echo("Building base image failed with following error:") echo(err) return None image = self.image_by_tag(basetag) echo("Built base image {0} (Id: {1})".format(basetag, image['Id'])) return image
module function_definition identifier parameters identifier identifier block expression_statement call identifier argument_list expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier attribute attribute identifier identifier identifier if_statement call attribute identifier identifier argument_list keyword_argument identifier identifier block if_statement not_operator identifier block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier return_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier expression_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier true keyword_argument identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier if_statement identifier block expression_statement call identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list identifier return_statement none expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier subscript identifier string string_start string_content string_end return_statement identifier
Build the glusterbase image
def post_process_images(self, doctree): super(AbstractSlideBuilder, self).post_process_images(doctree) relative_base = ( ['..'] * doctree.attributes.get('source')[len(self.srcdir) + 1:].count('/') ) for node in doctree.traverse(nodes.image): if node.get('candidates') is None: node['candidates'] = ('*',) if node['uri'].startswith(self.outdir): node['uri'] = '/'.join( relative_base + [ node['uri'][len(self.outdir) + 1:] ] )
module function_definition identifier parameters identifier identifier block expression_statement call attribute call identifier argument_list identifier identifier identifier argument_list identifier expression_statement assignment identifier parenthesized_expression binary_operator list string string_start string_content string_end call attribute subscript call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end slice binary_operator call identifier argument_list attribute identifier identifier integer identifier argument_list string string_start string_content string_end for_statement identifier call attribute identifier identifier argument_list attribute identifier identifier block if_statement comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end none block expression_statement assignment subscript identifier string string_start string_content string_end tuple string string_start string_content string_end if_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list attribute identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list binary_operator identifier list subscript subscript identifier string string_start string_content string_end slice binary_operator call identifier argument_list attribute identifier identifier integer
Pick the best candidate for all image URIs.
def create_transaction(self, *args: Any, **kwargs: Any) -> BaseTransaction: return self.get_transaction_class()(*args, **kwargs)
module function_definition identifier parameters identifier typed_parameter list_splat_pattern identifier type identifier typed_parameter dictionary_splat_pattern identifier type identifier type identifier block return_statement call call attribute identifier identifier argument_list argument_list list_splat identifier dictionary_splat identifier
Proxy for instantiating a signed transaction for this VM.
def _find_unused_partition() -> RootPartitions: which = subprocess.check_output(['ot-unused-partition']).strip() return {b'2': RootPartitions.TWO, b'3': RootPartitions.THREE}[which]
module function_definition identifier parameters type identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list list string string_start string_content string_end identifier argument_list return_statement subscript dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier identifier
Find the currently-unused root partition to write to
def _build_model_factories(store): result = {} for schemaname in store: schema = None try: schema = store[schemaname]['schema'] except KeyError: schemata_log("No schema found for ", schemaname, lvl=critical, exc=True) try: result[schemaname] = warmongo.model_factory(schema) except Exception as e: schemata_log("Could not create factory for schema ", schemaname, schema, lvl=critical, exc=True) return result
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary for_statement identifier identifier block expression_statement assignment identifier none try_statement block expression_statement assignment identifier subscript subscript identifier identifier string string_start string_content string_end except_clause identifier block expression_statement call identifier argument_list string string_start string_content string_end identifier keyword_argument identifier identifier keyword_argument identifier true try_statement block expression_statement assignment subscript identifier identifier call attribute identifier identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call identifier argument_list string string_start string_content string_end identifier identifier keyword_argument identifier identifier keyword_argument identifier true return_statement identifier
Generate factories to construct objects from schemata
def collect(self): instances = {} for device in os.listdir('/dev/'): instances.update(self.match_device(device, '/dev/')) for device_id in os.listdir('/dev/disk/by-id/'): instances.update(self.match_device(device, '/dev/disk/by-id/')) metrics = {} for device, p in instances.items(): output = p.communicate()[0].strip() try: metrics[device + ".Temperature"] = float(output) except: self.log.warn('Disk temperature retrieval failed on ' + device) for metric in metrics.keys(): self.publish(metric, metrics[metric])
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 call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier string string_start string_content string_end for_statement identifier call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier dictionary for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute subscript call attribute identifier identifier argument_list integer identifier argument_list try_statement block expression_statement assignment subscript identifier binary_operator identifier string string_start string_content string_end call identifier argument_list identifier except_clause block expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end identifier for_statement identifier call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list identifier subscript identifier identifier
Collect and publish disk temperatures
def remote_resolve_reference(self, ref, remote='origin'): return git_remote_resolve_reference(self.repo_dir, ref, remote=remote)
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end block return_statement call identifier argument_list attribute identifier identifier identifier keyword_argument identifier identifier
Resolve a reference to a remote revision.
def cas2tas(Vcas, H): p, rho, T = atmos(H) qdyn = p0*((1.+rho0*Vcas*Vcas/(7.*p0))**3.5-1.) Vtas = np.sqrt(7.*p/rho*((1.+qdyn/p)**(2./7.)-1.)) return Vtas
module function_definition identifier parameters identifier identifier block expression_statement assignment pattern_list identifier identifier identifier call identifier argument_list identifier expression_statement assignment identifier binary_operator identifier parenthesized_expression binary_operator binary_operator parenthesized_expression binary_operator float binary_operator binary_operator binary_operator identifier identifier identifier parenthesized_expression binary_operator float identifier float float expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator binary_operator binary_operator float identifier identifier parenthesized_expression binary_operator binary_operator parenthesized_expression binary_operator float binary_operator identifier identifier parenthesized_expression binary_operator float float float return_statement identifier
Calibrated Airspeed to True Airspeed
def fill_attrs(self, attrs): for trname, attrname in self.transitions_at.items(): implem = self.implementations[trname] if attrname in attrs: conflicting = attrs[attrname] if not self._may_override(implem, conflicting): raise ValueError( "Can't override transition implementation %s=%r with %r" % (attrname, conflicting, implem)) attrs[attrname] = implem return attrs
module function_definition identifier parameters identifier identifier block for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block expression_statement assignment identifier subscript attribute identifier identifier identifier if_statement comparison_operator identifier identifier block expression_statement assignment identifier subscript identifier identifier if_statement not_operator call attribute identifier identifier argument_list identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier identifier expression_statement assignment subscript identifier identifier identifier return_statement identifier
Update the 'attrs' dict with generated ImplementationProperty.
def summarize_crud_mutation(method, model, isAsync=False): action_type = get_crud_action(method=method, model=model) name = crud_mutation_name(model=model, action=method) input_map = { 'create': create_mutation_inputs, 'update': update_mutation_inputs, 'delete': delete_mutation_inputs, } output_map = { 'create': create_mutation_outputs, 'update': update_mutation_outputs, 'delete': delete_mutation_outputs, } inputs = input_map[method](model) outputs = output_map[method](model) return summarize_mutation( mutation_name=name, event=action_type, isAsync=isAsync, inputs=inputs, outputs=outputs )
module function_definition identifier parameters identifier identifier default_parameter identifier false block expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier expression_statement assignment identifier call subscript identifier identifier argument_list identifier expression_statement assignment identifier call subscript identifier identifier argument_list identifier return_statement call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
This function provides the standard form for crud mutations.
def _get_platform_name(ncattr): match = re.match(r'G-(\d+)', ncattr) if match: return SPACECRAFTS.get(int(match.groups()[0])) return None
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement identifier block return_statement call attribute identifier identifier argument_list call identifier argument_list subscript call attribute identifier identifier argument_list integer return_statement none
Determine name of the platform
def addRnaQuantification(self): self._openRepo() dataset = self._repo.getDatasetByName(self._args.datasetName) biosampleId = "" if self._args.biosampleName: biosample = dataset.getBiosampleByName(self._args.biosampleName) biosampleId = biosample.getId() if self._args.name is None: name = getNameFromPath(self._args.quantificationFilePath) else: name = self._args.name programs = "" featureType = "gene" if self._args.transcript: featureType = "transcript" rnaseq2ga.rnaseq2ga( self._args.quantificationFilePath, self._args.filePath, name, self._args.format, dataset=dataset, featureType=featureType, description=self._args.description, programs=programs, featureSetNames=self._args.featureSetNames, readGroupSetNames=self._args.readGroupSetName, biosampleId=biosampleId)
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier expression_statement assignment identifier string string_start string_end if_statement attribute attribute identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator attribute attribute identifier identifier identifier none block expression_statement assignment identifier call identifier argument_list attribute attribute identifier identifier identifier else_clause block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier string string_start string_end expression_statement assignment identifier string string_start string_content string_end if_statement attribute attribute identifier identifier identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier identifier attribute attribute identifier identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute attribute identifier 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 identifier
Adds an rnaQuantification into this repo
def _from_dict(cls, _dict): args = {} if 'count' in _dict: args['count'] = _dict.get('count') if 'relevance' in _dict: args['relevance'] = _dict.get('relevance') if 'text' in _dict: args['text'] = _dict.get('text') if 'emotion' in _dict: args['emotion'] = EmotionScores._from_dict(_dict.get('emotion')) if 'sentiment' in _dict: args['sentiment'] = FeatureSentimentResults._from_dict( _dict.get('sentiment')) return cls(**args)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier 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 if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end return_statement call identifier argument_list dictionary_splat identifier
Initialize a KeywordsResult object from a json dictionary.
def print_datetime_object(dt): print(dt) print('ctime :', dt.ctime()) print('tuple :', dt.timetuple()) print('ordinal:', dt.toordinal()) print('Year :', dt.year) print('Mon :', dt.month) print('Day :', dt.day)
module function_definition identifier parameters identifier block expression_statement call identifier argument_list identifier expression_statement call identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list expression_statement call identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list expression_statement call identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list expression_statement call identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement call identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement call identifier argument_list string string_start string_content string_end attribute identifier identifier
prints a date-object
def A(*a): return np.array(a[0]) if len(a)==1 else [np.array(o) for o in a]
module function_definition identifier parameters list_splat_pattern identifier block return_statement conditional_expression call attribute identifier identifier argument_list subscript identifier integer comparison_operator call identifier argument_list identifier integer list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier identifier
convert iterable object into numpy array
def float_input(self, question, message='Invalid entry', default=None, required=True): float_result = None requiredFlag = True while (float_result is None and requiredFlag): result = input('%s: ' % question) if not result and not required: float_result = None requiredFlag = False if not result and default: float_result = default if float_result is None and requiredFlag: try: float_result = float(result) except ValueError: self.stdout.write(self.style.ERROR(message)) float_result = None return float_result
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_content string_end default_parameter identifier none default_parameter identifier true block expression_statement assignment identifier none expression_statement assignment identifier true while_statement parenthesized_expression boolean_operator comparison_operator identifier none identifier block expression_statement assignment identifier call identifier argument_list binary_operator string string_start string_content string_end identifier if_statement boolean_operator not_operator identifier not_operator identifier block expression_statement assignment identifier none expression_statement assignment identifier false if_statement boolean_operator not_operator identifier identifier block expression_statement assignment identifier identifier if_statement boolean_operator comparison_operator identifier none identifier block try_statement block expression_statement assignment identifier call identifier argument_list identifier except_clause identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier none return_statement identifier
Method for floating point inputs with optionally specifiable error message.
def AvgPool3D(a, k, strides, padding): patches = _pool_patches(a, k, strides, padding.decode("ascii")) return np.average(patches, axis=tuple(range(-len(k), 0))),
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end return_statement expression_list call attribute identifier identifier argument_list identifier keyword_argument identifier call identifier argument_list call identifier argument_list unary_operator call identifier argument_list identifier integer
Average 3D pooling op.
def start_simple_server(): "A simple mail server that sends a simple response" args = _get_args() addr = ('', args.port) DebuggingServer(addr, None) asyncore.loop()
module function_definition identifier parameters block expression_statement string string_start string_content string_end expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier tuple string string_start string_end attribute identifier identifier expression_statement call identifier argument_list identifier none expression_statement call attribute identifier identifier argument_list
A simple mail server that sends a simple response
def instance(self, skip_exist_test=False): model = self.database._models[self.related_to] meth = model.lazy_connect if skip_exist_test else model return meth(self.proxy_get())
module function_definition identifier parameters identifier default_parameter identifier false block expression_statement assignment identifier subscript attribute attribute identifier identifier identifier attribute identifier identifier expression_statement assignment identifier conditional_expression attribute identifier identifier identifier identifier return_statement call identifier argument_list call attribute identifier identifier argument_list
Returns the instance of the related object linked by the field.
def MemoryExceeded(self): rss_size = self.proc.memory_info().rss return rss_size // 1024 // 1024 > config.CONFIG["Client.rss_max"]
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute call attribute attribute identifier identifier identifier argument_list identifier return_statement comparison_operator binary_operator binary_operator identifier integer integer subscript attribute identifier identifier string string_start string_content string_end
Returns True if our memory footprint is too large.
def instrs_to_body(instrs, context): stack = [] body = [] process_instrs(instrs, stack, body, context) if stack: raise DecompilationError( "Non-empty stack at the end of instrs_to_body(): %s." % stack ) return body
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list expression_statement assignment identifier list expression_statement call identifier argument_list identifier identifier identifier identifier if_statement identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier return_statement identifier
Convert a list of Instruction objects to a list of AST body nodes.
def main(flags): dl = SheetDownloader(flags) dl.init() for file_info in settings.GOOGLE_SHEET_SYNC['files']: print('Downloading {}'.format(file_info['path'])) dl.download_sheet( file_info['path'], file_info['sheet'], file_info['range'], )
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list for_statement identifier subscript attribute identifier identifier string string_start string_content string_end block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list subscript identifier string string_start string_content string_end expression_statement 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
Download all sheets as configured.
def load_template_help(builtin): help_file = "templates/%s-help.yml" % builtin help_file = resource_filename(__name__, help_file) help_obj = {} if os.path.exists(help_file): help_data = yaml.safe_load(open(help_file)) if 'name' in help_data: help_obj['name'] = help_data['name'] if 'help' in help_data: help_obj['help'] = help_data['help'] if 'args' in help_data: help_obj['args'] = help_data['args'] return help_obj
module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier dictionary if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list identifier if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end return_statement identifier
Loads the help for a given template
def copy(self): return LabeledTree( udepth = self.udepth, depth = self.depth, text = self.text, label = self.label, children = self.children.copy() if self.children != None else [], parent = self.parent)
module function_definition identifier parameters identifier block return_statement call identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier conditional_expression call attribute attribute identifier identifier identifier argument_list comparison_operator attribute identifier identifier none list keyword_argument identifier attribute identifier identifier
Deep Copy of a LabeledTree
def load(self, filename=None): assert not self.__flag_loaded, "File can be loaded only once" if filename is None: filename = self.default_filename assert filename is not None, \ "{0!s} class has no default filename".format(self.__class__.__name__) size = os.path.getsize(filename) if size == 0: raise RuntimeError("Empty file: '{0!s}'".format(filename)) self._test_magic(filename) self._do_load(filename) self.filename = filename self.__flag_loaded = True
module function_definition identifier parameters identifier default_parameter identifier none block assert_statement not_operator attribute identifier identifier string string_start string_content string_end if_statement comparison_operator identifier none block expression_statement assignment identifier attribute identifier identifier assert_statement comparison_operator identifier none call attribute string string_start string_content string_end identifier argument_list attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator identifier integer block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier true
Loads file and registers filename as attribute.
def _make_client(self): self._logger.debug('setting initial watchman timeout to %s', self._startup_timeout) return StreamableWatchmanClient(sockpath=self.socket, transport='local', timeout=self._startup_timeout)
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end attribute identifier identifier return_statement call identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier attribute identifier identifier
Create a new watchman client using the BSER protocol over a UNIX socket.
def update(self, storagemodel:object, modeldefinition = None, hide = 0) -> StorageQueueModel: if (storagemodel.id != '') and (storagemodel.pop_receipt != '') and (not storagemodel.id is None) and (not storagemodel.pop_receipt is None): try: content = storagemodel.getmessage() message = modeldefinition['queueservice'].update_message(storagemodel._queuename, storagemodel.id, storagemodel.pop_receipt, visibility_timeout = hide, content=content) storagemodel.content = content storagemodel.pop_receipt = message.pop_receipt except Exception as e: msg = 'can not update queue message: queue {} with message.id {!s} because {!s}'.format(storagemodel._queuename, storagemodel.id, e) storagemodel = None raise AzureStorageWrapException(msg=msg) else: msg = 'cant update queuemessage in {!s} due to missing id {!s} and/or pop_receipt {!s}'.format(storagemodel._queuename, storagemodel.id, storagemodel.pop_receipt) storagemodel = None raise AzureStorageWrapException(msg=msg) return storagemodel
module function_definition identifier parameters identifier typed_parameter identifier type identifier default_parameter identifier none default_parameter identifier integer type identifier block if_statement boolean_operator boolean_operator boolean_operator parenthesized_expression comparison_operator attribute identifier identifier string string_start string_end parenthesized_expression comparison_operator attribute identifier identifier string string_start string_end parenthesized_expression not_operator comparison_operator attribute identifier identifier none parenthesized_expression not_operator comparison_operator attribute identifier identifier none block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier attribute identifier identifier identifier expression_statement assignment identifier none raise_statement call identifier argument_list keyword_argument identifier identifier else_clause block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement assignment identifier none raise_statement call identifier argument_list keyword_argument identifier identifier return_statement identifier
update the message in queue
def remove_sample_prep_workflow(portal): logger.info("Removing 'sample_prep' related states and transitions ...") workflow_ids = ["bika_sample_workflow", "bika_ar_workflow", "bika_analysis_workflow"] to_remove = ["sample_prep", "sample_prep_complete"] wf_tool = api.get_tool("portal_workflow") for wf_id in workflow_ids: workflow = wf_tool.getWorkflowById(wf_id) for state_trans in to_remove: if state_trans in workflow.transitions: logger.info("Removing transition '{}' from '{}'" .format(state_trans, wf_id)) workflow.transitions.deleteTransitions([state_trans]) if state_trans in workflow.states: logger.info("Removing state '{}' from '{}'" .format(state_trans, wf_id)) workflow.states.deleteStates([state_trans])
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier for_statement identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list list identifier if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list list identifier
Removes sample_prep and sample_prep_complete transitions
def write_output(self): for data in self.output_data.values(): self.create_output(data.get('key'), data.get('value'), data.get('type'))
module function_definition identifier parameters identifier block for_statement identifier call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end 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
Write all stored output data to storage.
def fetch_closed_orders(self, limit: int) -> List[Order]: return self._fetch_orders_limit(self._closed_orders, limit)
module function_definition identifier parameters identifier typed_parameter identifier type identifier type generic_type identifier type_parameter type identifier block return_statement call attribute identifier identifier argument_list attribute identifier identifier identifier
Fetch latest closed orders, must provide a limit.
def should_log(self, logger_name: str, level: str) -> bool: if (logger_name, level) not in self._should_log: log_level_per_rule = self._get_log_level(logger_name) log_level_per_rule_numeric = getattr(logging, log_level_per_rule.upper(), 10) log_level_event_numeric = getattr(logging, level.upper(), 10) should_log = log_level_event_numeric >= log_level_per_rule_numeric self._should_log[(logger_name, level)] = should_log return self._should_log[(logger_name, level)]
module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_parameter identifier type identifier type identifier block if_statement comparison_operator tuple identifier identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier call attribute identifier identifier argument_list integer expression_statement assignment identifier call identifier argument_list identifier call attribute identifier identifier argument_list integer expression_statement assignment identifier comparison_operator identifier identifier expression_statement assignment subscript attribute identifier identifier tuple identifier identifier identifier return_statement subscript attribute identifier identifier tuple identifier identifier
Returns if a message for the logger should be logged.
def assign(self, subject): if not isinstance(subject, (Publisher, Subscriber)): raise TypeError('Assignee has to be Publisher or Subscriber') if self._subject is not None: raise SubscriptionError('Topic %r already assigned' % self._path) self._subject = subject if self._subscriptions: self._subject.subscribe(self) if self._pre_assign_emit is not None: for value in self._pre_assign_emit: self._subject.emit(value, who=self) self._pre_assign_emit = None return subject
module function_definition identifier parameters identifier identifier block if_statement not_operator call identifier argument_list identifier tuple identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end if_statement comparison_operator attribute identifier identifier none block raise_statement call identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier expression_statement assignment attribute identifier identifier identifier if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator attribute identifier identifier none block for_statement identifier attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier identifier expression_statement assignment attribute identifier identifier none return_statement identifier
Assigns the given subject to the topic
def _get_requested_databases(self): requested_databases = [] if ((self._requested_namespaces is not None) and (self._requested_namespaces != [])): for requested_namespace in self._requested_namespaces: if requested_namespace[0] is '*': return [] elif requested_namespace[0] not in IGNORE_DBS: requested_databases.append(requested_namespace[0]) return requested_databases
module function_definition identifier parameters identifier block expression_statement assignment identifier list if_statement parenthesized_expression boolean_operator parenthesized_expression comparison_operator attribute identifier identifier none parenthesized_expression comparison_operator attribute identifier identifier list block for_statement identifier attribute identifier identifier block if_statement comparison_operator subscript identifier integer string string_start string_content string_end block return_statement list elif_clause comparison_operator subscript identifier integer identifier block expression_statement call attribute identifier identifier argument_list subscript identifier integer return_statement identifier
Returns a list of databases requested, not including ignored dbs
def method(func): attr = abc.abstractmethod(func) attr.__imethod__ = True return attr
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier true return_statement identifier
Wrap a function as a method.
def make_random_xml_file(fname, num_elements=200, depth=3): with open(fname, 'w') as f: f.write('<?xml version="1.0" ?>\n<random>\n') for dep_num, _ in enumerate(range(1,depth)): f.write(' <depth>\n <content>\n') for num, _ in enumerate(range(1, num_elements)): f.write(' <stuff>data line ' + str(num) + '</stuff>\n') f.write(' </content>\n </depth>\n') f.write('</random>\n')
module function_definition identifier parameters identifier default_parameter identifier integer default_parameter identifier integer block with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence escape_sequence string_end for_statement pattern_list identifier identifier call identifier argument_list call identifier argument_list integer identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence escape_sequence string_end for_statement pattern_list identifier identifier call identifier argument_list call identifier argument_list integer identifier block expression_statement call attribute identifier identifier argument_list binary_operator binary_operator string string_start string_content string_end call identifier argument_list identifier string string_start string_content escape_sequence string_end expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence escape_sequence string_end expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end
makes a random xml file mainly for testing the xml_split
def del_aldb(self, mem_addr: int): self._aldb.del_record(mem_addr) self._aldb.add_loaded_callback(self._aldb_loaded_callback)
module function_definition identifier parameters identifier typed_parameter identifier type identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier
Delete an All-Link Database record.
def on_status(self, status): self.out.write(json.dumps(status)) self.out.write(os.linesep) self.received += 1 return not self.terminate
module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement augmented_assignment attribute identifier identifier integer return_statement not_operator attribute identifier identifier
Print out some tweets
def top(self): for child in self.children(skip_not_present=False): if not isinstance(child, AddrmapNode): continue return child raise RuntimeError
module function_definition identifier parameters identifier block for_statement identifier call attribute identifier identifier argument_list keyword_argument identifier false block if_statement not_operator call identifier argument_list identifier identifier block continue_statement return_statement identifier raise_statement identifier
Returns the top-level addrmap node
def enable(ctx): if ctx.obj['username'] is None: log('Specify the username with "iso db user --username ..."') return change_user = ctx.obj['db'].objectmodels['user'].find_one({ 'name': ctx.obj['username'] }) change_user.active = True change_user.save() log('Done')
module function_definition identifier parameters identifier block if_statement comparison_operator subscript attribute identifier identifier string string_start string_content string_end none block expression_statement call identifier argument_list string string_start string_content string_end return_statement expression_statement assignment identifier call attribute subscript attribute subscript attribute identifier identifier string string_start string_content string_end identifier string string_start string_content string_end identifier argument_list dictionary pair string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier true expression_statement call attribute identifier identifier argument_list expression_statement call identifier argument_list string string_start string_content string_end
Enable an existing user
def parseCustom(self, xbrl, ignore_errors=0): custom_obj = Custom() custom_data = xbrl.find_all(re.compile('^((?!(us-gaap|dei|xbrll|xbrldi)).)*:\s*', re.IGNORECASE | re.MULTILINE)) elements = {} for data in custom_data: if XBRLParser().is_number(data.text): setattr(custom_obj, data.name.split(':')[1], data.text) return custom_obj
module function_definition identifier parameters identifier identifier default_parameter identifier integer block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end binary_operator attribute identifier identifier attribute identifier identifier expression_statement assignment identifier dictionary for_statement identifier identifier block if_statement call attribute call identifier argument_list identifier argument_list attribute identifier identifier block expression_statement call identifier argument_list identifier subscript call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end integer attribute identifier identifier return_statement identifier
Parse company custom entities from XBRL and return an Custom object.
def queue_context_entry(exchange, queue_name, routing=None): if routing is None: routing = queue_name queue_entry = QueueContextEntry(mq_queue=queue_name, mq_exchange=exchange, mq_routing_key=routing) return queue_entry
module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier return_statement identifier
forms queue's context entry
def format_address(address): if address.kind == ArgumentKind.regular: return address.name return "{0}[{1}]".format(address.name, address.key)
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block return_statement attribute identifier identifier return_statement call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier attribute identifier identifier
Formats an ArgumentAddress for human reading.
def _process(self, name): if self.token.nature == name: self.token = self.lexer.next_token() else: self._error()
module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute attribute identifier identifier identifier identifier block expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list else_clause block expression_statement call attribute identifier identifier argument_list
Process the current token.
def structparser(token): m = STRUCT_PACK_RE.match(token) if not m: return [token] else: endian = m.group('endian') if endian is None: return [token] formatlist = re.findall(STRUCT_SPLIT_RE, m.group('fmt')) fmt = ''.join([f[-1] * int(f[:-1]) if len(f) != 1 else f for f in formatlist]) if endian == '@': if byteorder == 'little': endian = '<' else: assert byteorder == 'big' endian = '>' if endian == '<': tokens = [REPLACEMENTS_LE[c] for c in fmt] else: assert endian == '>' tokens = [REPLACEMENTS_BE[c] for c in fmt] return tokens
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement not_operator identifier block return_statement list identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier none block return_statement list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute string string_start string_end identifier argument_list list_comprehension conditional_expression binary_operator subscript identifier unary_operator integer call identifier argument_list subscript identifier slice unary_operator integer comparison_operator call identifier argument_list identifier integer identifier for_in_clause identifier identifier if_statement comparison_operator identifier string string_start string_content string_end block if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier string string_start string_content string_end else_clause block assert_statement comparison_operator identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier list_comprehension subscript identifier identifier for_in_clause identifier identifier else_clause block assert_statement comparison_operator identifier string string_start string_content string_end expression_statement assignment identifier list_comprehension subscript identifier identifier for_in_clause identifier identifier return_statement identifier
Parse struct-like format string token into sub-token list.
def _handle_api(self, handler, handler_args, handler_kwargs): try: status_code, return_value = handler(*handler_args, **handler_kwargs) except APIError as error: return error.send() web.ctx.status = _convert_http_status(status_code) return _api_convert_output(return_value)
module function_definition identifier parameters identifier identifier identifier identifier block try_statement block expression_statement assignment pattern_list identifier identifier call identifier argument_list list_splat identifier dictionary_splat identifier except_clause as_pattern identifier as_pattern_target identifier block return_statement call attribute identifier identifier argument_list expression_statement assignment attribute attribute identifier identifier identifier call identifier argument_list identifier return_statement call identifier argument_list identifier
Handle call to subclasses and convert the output to an appropriate value
def parse_substitution_from_list(list_rep): if type(list_rep) is not list: raise SyntaxError('Substitution must be a list') if len(list_rep) < 2: raise SyntaxError('Substitution must be a list of size 2') pattern = list_rep[0] replacement = list_rep[1] is_multiline = False if (len(list_rep) > 2): is_multiline = list_rep[2] if type(is_multiline) is not bool: raise SyntaxError('is_multiline must be a boolean') result = substitute.Substitution(pattern, replacement, is_multiline) return result
module function_definition identifier parameters identifier block if_statement comparison_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end if_statement comparison_operator call identifier argument_list identifier integer block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier subscript identifier integer expression_statement assignment identifier subscript identifier integer expression_statement assignment identifier false if_statement parenthesized_expression comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier subscript identifier integer if_statement comparison_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier return_statement identifier
Parse a substitution from the list representation in the config file.
def _find_function(name, region=None, key=None, keyid=None, profile=None): conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) for funcs in __utils__['boto3.paged_call'](conn.list_functions): for func in funcs['Functions']: if func['FunctionName'] == name: return func return None
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier for_statement identifier call subscript identifier string string_start string_content string_end argument_list attribute identifier identifier block for_statement identifier subscript identifier string string_start string_content string_end block if_statement comparison_operator subscript identifier string string_start string_content string_end identifier block return_statement identifier return_statement none
Given function name, find and return matching Lambda information.
def getData(self, events): if self.interval not in ["1d", "1wk", "1mo"]: raise ValueError("Incorrect interval: valid intervals are 1d, 1wk, 1mo") url = self.api_url % (self.ticker, self.start, self.end, self.interval, events, self.crumb) data = requests.get(url, cookies={'B':self.cookie}) content = StringIO(data.content.decode("utf-8")) return pd.read_csv(content, sep=',')
module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier binary_operator attribute identifier identifier tuple attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier dictionary pair string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end
Returns a list of historical data from Yahoo Finance
def _directory (self): if self._filename is None: return os.path.join(self._ROOT_DIR, 'config') else: return os.path.dirname(self._filename)
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block return_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier string string_start string_content string_end else_clause block return_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier
The directory for this AitConfig.
def allocate(self): self.logger.debug("Allocating environment.") self._allocate() self.logger.debug("Environment successfully allocated.")
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end
Builds the context and the Hooks.
def _setup_packages(self, sc): packages = self.py_packages if not packages: return for package in packages: mod = importlib.import_module(package) try: mod_path = mod.__path__[0] except AttributeError: mod_path = mod.__file__ tar_path = os.path.join(self.run_path, package + '.tar.gz') tar = tarfile.open(tar_path, "w:gz") tar.add(mod_path, os.path.basename(mod_path)) tar.close() sc.addPyFile(tar_path)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier if_statement not_operator identifier block return_statement for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier try_statement block expression_statement assignment identifier subscript attribute identifier identifier integer except_clause identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier binary_operator identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier
This method compresses and uploads packages to the cluster
def _force_close(self): if self._sock: try: self._sock.close() except: pass self._sock = None self._rfile = None
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list except_clause block pass_statement expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier none
Close connection without QUIT message
def shell_out_ignore_exitcode(cmd, stderr=STDOUT, cwd=None): try: return shell_out(cmd, stderr=stderr, cwd=cwd) except CalledProcessError as c: return _clean_output(c.output)
module function_definition identifier parameters identifier default_parameter identifier identifier default_parameter identifier none block try_statement block return_statement call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier except_clause as_pattern identifier as_pattern_target identifier block return_statement call identifier argument_list attribute identifier identifier
Same as shell_out but doesn't raise if the cmd exits badly.
def folder_name(self): name = self.site_packages_name if name is None: name = self.name return name
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier attribute identifier identifier return_statement identifier
The name of the build folders containing this recipe.
def gen_smul(src1, src2, dst): assert src1.size == src2.size return ReilBuilder.build(ReilMnemonic.SMUL, src1, src2, dst)
module function_definition identifier parameters identifier identifier identifier block assert_statement comparison_operator attribute identifier identifier attribute identifier identifier return_statement call attribute identifier identifier argument_list attribute identifier identifier identifier identifier identifier
Return a SMUL instruction.
def string(self, *args): data = self.bytes(*args) if data is not None: return data.rstrip(b"\x00").decode('utf-8')
module function_definition identifier parameters identifier list_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list list_splat identifier if_statement comparison_operator identifier none block return_statement call attribute call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end identifier argument_list string string_start string_content string_end
return string stored in node
def update_image(self, data): if 1 in data.shape: data = data.squeeze() if self.conf.contrast_level is not None: clevels = [self.conf.contrast_level, 100.0-self.conf.contrast_level] imin, imax = np.percentile(data, clevels) data = np.clip((data - imin)/(imax - imin + 1.e-8), 0, 1) self.axes.images[0].set_data(data) self.canvas.draw()
module function_definition identifier parameters identifier identifier block if_statement comparison_operator integer attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator attribute attribute identifier identifier identifier none block expression_statement assignment identifier list attribute attribute identifier identifier identifier binary_operator float attribute attribute identifier identifier identifier expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator parenthesized_expression binary_operator identifier identifier parenthesized_expression binary_operator binary_operator identifier identifier float integer integer expression_statement call attribute subscript attribute attribute identifier identifier identifier integer identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list
update image on panel, as quickly as possible
def fragment(pkt, fragsize=1480): fragsize = (fragsize + 7) // 8 * 8 lst = [] for p in pkt: s = bytes(p[IP].payload) nb = (len(s) + fragsize - 1) // fragsize for i in range(nb): q = p.copy() del q[IP].payload del q[IP].chksum del q[IP].len if i == nb - 1: q[IP].flags &= ~1 else: q[IP].flags |= 1 q[IP].frag = i * fragsize // 8 r = conf.raw_layer(load=s[i * fragsize:(i + 1) * fragsize]) r.overload_fields = p[IP].payload.overload_fields.copy() q.add_payload(r) lst.append(q) return lst
module function_definition identifier parameters identifier default_parameter identifier integer block expression_statement assignment identifier binary_operator binary_operator parenthesized_expression binary_operator identifier integer integer integer expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment identifier call identifier argument_list attribute subscript identifier identifier identifier expression_statement assignment identifier binary_operator parenthesized_expression binary_operator binary_operator call identifier argument_list identifier identifier integer identifier for_statement identifier call identifier argument_list identifier block expression_statement assignment identifier call attribute identifier identifier argument_list delete_statement attribute subscript identifier identifier identifier delete_statement attribute subscript identifier identifier identifier delete_statement attribute subscript identifier identifier identifier if_statement comparison_operator identifier binary_operator identifier integer block expression_statement augmented_assignment attribute subscript identifier identifier identifier unary_operator integer else_clause block expression_statement augmented_assignment attribute subscript identifier identifier identifier integer expression_statement assignment attribute subscript identifier identifier identifier binary_operator binary_operator identifier identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier subscript identifier slice binary_operator identifier identifier binary_operator parenthesized_expression binary_operator identifier integer identifier expression_statement assignment attribute identifier identifier call attribute attribute attribute subscript identifier identifier identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Fragment a big IP datagram
def update(self, new_data: IntentDict): for locale, data in new_data.items(): if locale not in self.dict: self.dict[locale] = {} self.dict[locale].update(data)
module function_definition identifier parameters identifier typed_parameter identifier type identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier dictionary expression_statement call attribute subscript attribute identifier identifier identifier identifier argument_list identifier
Receive an update from the loaders.
def ifar(self, coinc_stat): n = self.coincs.num_greater(coinc_stat) return self.background_time / lal.YRJUL_SI / (n + 1)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier return_statement binary_operator binary_operator attribute identifier identifier attribute identifier identifier parenthesized_expression binary_operator identifier integer
Return the far that would be associated with the coincident given.
def unmarshal(self, value, bind_client=None): if not isinstance(value, self.type): o = self.type() if bind_client is not None and hasattr(o.__class__, 'bind_client'): o.bind_client = bind_client if isinstance(value, dict): for (k, v) in value.items(): if not hasattr(o.__class__, k): self.log.warning("Unable to set attribute {0} on entity {1!r}".format(k, o)) else: setattr(o, k, v) value = o else: raise Exception("Unable to unmarshall object {0!r}".format(value)) return value
module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement not_operator call identifier argument_list identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement boolean_operator comparison_operator identifier none call identifier argument_list attribute identifier identifier string string_start string_content string_end block expression_statement assignment attribute identifier identifier identifier if_statement call identifier argument_list identifier identifier block for_statement tuple_pattern identifier identifier call attribute identifier identifier argument_list block if_statement not_operator call identifier argument_list attribute identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier else_clause block expression_statement call identifier argument_list identifier identifier identifier expression_statement assignment identifier identifier else_clause block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier return_statement identifier
Cast the specified value to the entity type.
async def handle_client_get_queue(self, client_addr, _: ClientGetQueue): jobs_running = list() for backend_job_id, content in self._job_running.items(): jobs_running.append((content[1].job_id, backend_job_id[0] == client_addr, self._registered_agents[content[0]], content[1].course_id+"/"+content[1].task_id, content[1].launcher, int(content[2]), int(content[2])+content[1].time_limit)) jobs_waiting = list() for job_client_addr, msg in self._waiting_jobs.items(): if isinstance(msg, ClientNewJob): jobs_waiting.append((msg.job_id, job_client_addr[0] == client_addr, msg.course_id+"/"+msg.task_id, msg.launcher, msg.time_limit)) await ZMQUtils.send_with_addr(self._client_socket, client_addr, BackendGetQueue(jobs_running, jobs_waiting))
module function_definition identifier parameters identifier identifier typed_parameter identifier type identifier block expression_statement assignment identifier call identifier argument_list for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list tuple attribute subscript identifier integer identifier comparison_operator subscript identifier integer identifier subscript attribute identifier identifier subscript identifier integer binary_operator binary_operator attribute subscript identifier integer identifier string string_start string_content string_end attribute subscript identifier integer identifier attribute subscript identifier integer identifier call identifier argument_list subscript identifier integer binary_operator call identifier argument_list subscript identifier integer attribute subscript identifier integer identifier expression_statement assignment identifier call identifier argument_list for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block if_statement call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list tuple attribute identifier identifier comparison_operator subscript identifier integer identifier binary_operator binary_operator attribute identifier identifier string string_start string_content string_end attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement await call attribute identifier identifier argument_list attribute identifier identifier identifier call identifier argument_list identifier identifier
Handles a ClientGetQueue message. Send back info about the job queue
def recv(self, filename, dest_file, timeout=None): transport = DataFilesyncTransport(self.stream) transport.write_data('RECV', filename, timeout) for data_msg in transport.read_until_done('DATA', timeout): dest_file.write(data_msg.data)
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none block expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier for_statement identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier
Retrieve a file from the device into the file-like dest_file.
def prettify_xml(xml_root): xml_string = etree.tostring(xml_root, encoding="utf-8", xml_declaration=True, pretty_print=True) return get_unicode_str(xml_string)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier true keyword_argument identifier true return_statement call identifier argument_list identifier
Returns pretty-printed string representation of element tree.
def download(args): downloader = Downloader(server_index_url = args.server_index_url) if args.packages: for pkg_id in args.packages: rv = downloader.download(info_or_id=unicode(pkg_id), download_dir=args.dir, quiet=args.quiet, force=args.force, halt_on_error=args.halt_on_error) if rv == False and args.halt_on_error: break else: downloader.download(download_dir=args.dir, quiet=args.quiet, force=args.force, halt_on_error=args.halt_on_error)
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list keyword_argument identifier attribute identifier identifier if_statement attribute identifier identifier block for_statement identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier call identifier argument_list identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier if_statement boolean_operator comparison_operator identifier false attribute identifier identifier block break_statement else_clause block expression_statement call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier
Download polyglot packages and models.
def defaultBuilder(value, nt): if callable(value): def logbuilder(V): try: value(V) except: _log.exception("Error in Builder") raise return logbuilder def builder(V): try: if isinstance(value, Value): V[None] = value elif isinstance(value, dict): for k, v in value.items(): V[k] = v else: nt.assign(V, value) except: _log.exception("Exception in Put builder") raise return builder
module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier block function_definition identifier parameters identifier block try_statement block expression_statement call identifier argument_list identifier except_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end raise_statement return_statement identifier function_definition identifier parameters identifier block try_statement block if_statement call identifier argument_list identifier identifier block expression_statement assignment subscript identifier none identifier elif_clause call identifier argument_list identifier identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement assignment subscript identifier identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier identifier except_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end raise_statement return_statement identifier
Reasonably sensible default handling of put builder
def block_ip(ip_address): if not ip_address: return if config.DISABLE_IP_LOCKOUT: return key = get_ip_blocked_cache_key(ip_address) if config.COOLOFF_TIME: REDIS_SERVER.set(key, 'blocked', config.COOLOFF_TIME) else: REDIS_SERVER.set(key, 'blocked') send_ip_block_signal(ip_address)
module function_definition identifier parameters identifier block if_statement not_operator identifier block return_statement if_statement attribute identifier identifier block return_statement expression_statement assignment identifier call identifier argument_list identifier if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier string string_start string_content string_end attribute identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier string string_start string_content string_end expression_statement call identifier argument_list identifier
given the ip, block it
def finish(self, status, response): self.response = binascii.hexlify(response).decode('utf-8') self.status = status self.runtime = monotonic() - self._start_time
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment attribute identifier identifier call attribute call attribute identifier identifier argument_list identifier identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier binary_operator call identifier argument_list attribute identifier identifier
Mark the end of a recorded RPC.
def center_image(self, img): img.anchor_x = img.width // 2 img.anchor_y = img.height // 2
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier binary_operator attribute identifier identifier integer expression_statement assignment attribute identifier identifier binary_operator attribute identifier identifier integer
Sets an image's anchor point to its center
def promptyn(msg, default=None): while True: yes = "Y" if default else "y" if default or default is None: no = "n" else: no = "N" confirm = prompt("%s [%s/%s]" % (msg, yes, no), "").lower() if confirm in ("y", "yes"): return True elif confirm in ("n", "no"): return False elif not confirm and default is not None: return default
module function_definition identifier parameters identifier default_parameter identifier none block while_statement true block expression_statement assignment identifier conditional_expression string string_start string_content string_end identifier string string_start string_content string_end if_statement boolean_operator identifier comparison_operator identifier none block expression_statement assignment identifier string string_start string_content string_end else_clause block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call attribute call identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier identifier string string_start string_end identifier argument_list if_statement comparison_operator identifier tuple string string_start string_content string_end string string_start string_content string_end block return_statement true elif_clause comparison_operator identifier tuple string string_start string_content string_end string string_start string_content string_end block return_statement false elif_clause boolean_operator not_operator identifier comparison_operator identifier none block return_statement identifier
Display a blocking prompt until the user confirms
def check_denovo_input(inputfile, params): background = params["background"] input_type = determine_file_type(inputfile) if input_type == "fasta": valid_bg = FA_VALID_BGS elif input_type in ["bed", "narrowpeak"]: genome = params["genome"] valid_bg = BED_VALID_BGS if "genomic" in background or "gc" in background: Genome(genome) check_bed_file(inputfile) else: sys.stderr.write("Format of inputfile {} not recognized.\n".format(inputfile)) sys.stderr.write("Input should be FASTA, BED or narrowPeak.\n") sys.stderr.write("See https://genome.ucsc.edu/FAQ/FAQformat.html for specifications.\n") sys.exit(1) for bg in background: if not bg in valid_bg: logger.info("Input type is %s, ignoring background type '%s'", input_type, bg) background = [bg for bg in background if bg in valid_bg] if len(background) == 0: logger.error("No valid backgrounds specified!") sys.exit(1) return input_type, background
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier identifier elif_clause comparison_operator identifier list string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier identifier if_statement boolean_operator comparison_operator string string_start string_content string_end identifier comparison_operator string string_start string_content string_end identifier block expression_statement call identifier argument_list identifier expression_statement call identifier argument_list identifier else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content escape_sequence string_end expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content escape_sequence string_end expression_statement call attribute identifier identifier argument_list integer for_statement identifier identifier block if_statement not_operator comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier expression_statement assignment identifier list_comprehension identifier for_in_clause identifier identifier if_clause comparison_operator identifier identifier if_statement comparison_operator call identifier argument_list identifier integer block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list integer return_statement expression_list identifier identifier
Check if an input file is valid, which means BED, narrowPeak or FASTA
def _gen_full_path(self, filename, file_system=None): if file_system is None: return '{}/{}'.format(self.dest_file_system, filename) else: if ":" not in file_system: raise ValueError("Invalid file_system specified: {}".format(file_system)) return '{}/{}'.format(file_system, filename)
module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement comparison_operator identifier none block return_statement call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier identifier else_clause block if_statement comparison_operator string string_start string_content string_end identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier return_statement call attribute string string_start string_content string_end identifier argument_list identifier identifier
Generate full file path on remote device.
def strip_accents(string): return u''.join( (character for character in unicodedata.normalize('NFD', string) if unicodedata.category(character) != 'Mn'))
module function_definition identifier parameters identifier block return_statement call attribute string string_start string_end identifier argument_list generator_expression identifier for_in_clause identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier if_clause comparison_operator call attribute identifier identifier argument_list identifier string string_start string_content string_end
Strip all the accents from the string
def vectorize_dialogues(self, dialogues): return np.array([self.vectorize_dialogue(d) for d in dialogues])
module function_definition identifier parameters identifier identifier block return_statement call attribute identifier identifier argument_list list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier identifier
Take in a list of dialogues and vectorize them all
def _handle_poll(self, relpath, params): request = json.loads(params.get('q')[0]) ret = {} for poll in request: _id = poll.get('id', None) path = poll.get('path', None) pos = poll.get('pos', 0) if path: abspath = os.path.normpath(os.path.join(self._root, path)) if os.path.isfile(abspath): with open(abspath, 'rb') as infile: if pos: infile.seek(pos) content = infile.read() ret[_id] = content.decode("utf-8") content = json.dumps(ret).encode("utf-8") self._send_content(content, 'application/json')
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list subscript call attribute identifier identifier argument_list string string_start string_content string_end integer expression_statement assignment identifier dictionary for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end none expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end none expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end integer if_statement identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier if_statement call attribute attribute identifier identifier identifier argument_list identifier block with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment subscript identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier string string_start string_content string_end
Handle poll requests for raw file contents.
def needsattached(func): @functools.wraps(func) def wrap(self, *args, **kwargs): if not self.attached: raise PositionError('Not attached to any process.') return func(self, *args, **kwargs) return wrap
module function_definition identifier parameters identifier block decorated_definition decorator call attribute identifier identifier argument_list identifier function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block if_statement not_operator attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end return_statement call identifier argument_list identifier list_splat identifier dictionary_splat identifier return_statement identifier
Decorator to prevent commands from being used when not attached.
def prompt_with_prob(self, orig_response=None, prob=None): if self.load_error: return 'Failed to read guidance config file' if hasattr(self.assignment, 'is_test'): log.info("Skipping prompt due to test mode") return "Test response" if prob is None: prob = self.prompt_probability if random.random() > prob: log.info("Did not prompt for rationale: Insufficient Probability") return "Did not prompt for rationale" with format.block(style="-"): rationale = prompt.explanation_msg(EXPLANTION_PROMPT, short_msg=CONFIRM_BLANK_EXPLANATION) if prob is None: self.prompt_probability = 0 if orig_response: print('Thanks! Your original response was: {}'.format('\n'.join(orig_response))) return rationale
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none block if_statement attribute identifier identifier block return_statement string string_start string_content string_end if_statement call identifier argument_list attribute identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement string string_start string_content string_end if_statement comparison_operator identifier none block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement string string_start string_content string_end with_statement with_clause with_item call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier if_statement comparison_operator identifier none block expression_statement assignment attribute identifier identifier integer if_statement identifier block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier return_statement identifier
Ask for rationale with a specific level of probability.
def replace_in_file(self, file_path, old_exp, new_exp): self.term.print_info(u"Making replacement into {}" .format(self.term.text_in_color(file_path, TERM_GREEN))) tmp_file = tempfile.NamedTemporaryFile(mode='w+t', delete=False) for filelineno, line in enumerate(io.open(file_path, encoding="utf-8")): if old_exp in line: line = line.replace(old_exp, new_exp) try: tmp_file.write(line.encode('utf-8')) except TypeError: tmp_file.write(line) name = tmp_file.name tmp_file.close() shutil.copy(name, file_path) os.remove(name)
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier false for_statement pattern_list identifier identifier call identifier argument_list call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end block if_statement comparison_operator identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier try_statement block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end except_clause identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list identifier
In the given file, replace all 'old_exp' by 'new_exp'.
def make_dist(name, version, **kwargs): summary = kwargs.pop('summary', 'Placeholder for summary') md = Metadata(**kwargs) md.name = name md.version = version md.summary = summary or 'Placeholder for summary' return Distribution(md)
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call identifier argument_list dictionary_splat identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier boolean_operator identifier string string_start string_content string_end return_statement call identifier argument_list identifier
A convenience method for making a dist given just a name and version.
def wp_status(self): try: print("Have %u of %u waypoints" % (self.wploader.count()+len(self.wp_received), self.wploader.expected_count)) except Exception: print("Have %u waypoints" % (self.wploader.count()+len(self.wp_received)))
module function_definition identifier parameters identifier block try_statement block expression_statement call identifier argument_list binary_operator string string_start string_content string_end tuple binary_operator call attribute attribute identifier identifier identifier argument_list call identifier argument_list attribute identifier identifier attribute attribute identifier identifier identifier except_clause identifier block expression_statement call identifier argument_list binary_operator string string_start string_content string_end parenthesized_expression binary_operator call attribute attribute identifier identifier identifier argument_list call identifier argument_list attribute identifier identifier
show status of wp download
def _handle_getconfig(self,cfg_file,*args,**options): if args: raise CommandError("supervisor getconfig takes no arguments") print cfg_file.read() return 0
module function_definition identifier parameters identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block if_statement identifier block raise_statement call identifier argument_list string string_start string_content string_end print_statement call attribute identifier identifier argument_list return_statement integer
Command 'supervisor getconfig' prints merged config to stdout.
def the_one(cls): if cls.THE_ONE is None: cls.THE_ONE = cls(settings.HELP_TOKENS_INI_FILE) return cls.THE_ONE
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier return_statement attribute identifier identifier
Get the single global HelpUrlExpert object.
def _refresh_aldb_records(self, linkcode, address, group): if self.aldb.status in [ALDBStatus.LOADED, ALDBStatus.PARTIAL]: for mem_addr in self.aldb: rec = self.aldb[mem_addr] if linkcode in [0, 1, 3]: if rec.control_flags.is_high_water_mark: _LOGGER.debug('Removing HWM record %04x', mem_addr) self.aldb.pop(mem_addr) elif not rec.control_flags.is_in_use: _LOGGER.debug('Removing not in use record %04x', mem_addr) self.aldb.pop(mem_addr) else: if rec.address == self.address and rec.group == group: _LOGGER.debug('Removing record %04x with addr %s and ' 'group %d', mem_addr, rec.address, rec.group) self.aldb.pop(mem_addr) self.read_aldb()
module function_definition identifier parameters identifier identifier identifier identifier block if_statement comparison_operator attribute attribute identifier identifier identifier list attribute identifier identifier attribute identifier identifier block for_statement identifier attribute identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier identifier if_statement comparison_operator identifier list integer integer integer block if_statement attribute attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier elif_clause not_operator attribute attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier else_clause block if_statement boolean_operator comparison_operator attribute identifier identifier attribute identifier identifier comparison_operator attribute identifier 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 identifier attribute identifier identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list
Refresh the IM and device ALDB records.
def _get_num_similar_objects(self, obj): return StatementLine.objects.filter( date=obj.date, amount=obj.amount, description=obj.description ).count()
module function_definition identifier parameters identifier identifier block return_statement call attribute call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier identifier argument_list
Get any statement lines which would be considered a duplicate of obj