code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def validate_registry_uri(uri: str) -> None: parsed = parse.urlparse(uri) scheme, authority, pkg_name, query = ( parsed.scheme, parsed.netloc, parsed.path, parsed.query, ) validate_registry_uri_scheme(scheme) validate_registry_uri_authority(authority) if query: validate_registry_uri_version(query) validate_package_name(pkg_name[1:])
module function_definition identifier parameters typed_parameter identifier type identifier type none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment pattern_list identifier identifier identifier identifier tuple attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement call identifier argument_list identifier expression_statement call identifier argument_list identifier if_statement identifier block expression_statement call identifier argument_list identifier expression_statement call identifier argument_list subscript identifier slice integer
Raise an exception if the URI does not conform to the registry URI scheme.
def load_shp(self, shapefile_name): shp_ext = 'shp' try: self.shp = open("%s.%s" % (shapefile_name, shp_ext), "rb") except IOError: try: self.shp = open("%s.%s" % (shapefile_name, shp_ext.upper()), "rb") except IOError: pass
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier string string_start string_content string_end try_statement block expression_statement assignment attribute identifier identifier call identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier string string_start string_content string_end except_clause identifier block try_statement block expression_statement assignment attribute identifier identifier call identifier argument_list binary_operator string string_start string_content string_end tuple identifier call attribute identifier identifier argument_list string string_start string_content string_end except_clause identifier block pass_statement
Attempts to load file with .shp extension as both lower and upper case
def remove_tenant_from_flavor(request, flavor, tenant): return _nova.novaclient(request).flavor_access.remove_tenant_access( flavor=flavor, tenant=tenant)
module function_definition identifier parameters identifier identifier identifier block return_statement call attribute attribute call attribute identifier identifier argument_list identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier
Remove a tenant from the given flavor access list.
def run_section(self, name, input_func=_stdin_): print('\nStuff %s by the license:\n' % name) section = self.survey[name] for question in section: self.run_question(question, input_func)
module function_definition identifier parameters identifier identifier default_parameter identifier identifier block expression_statement call identifier argument_list binary_operator string string_start string_content escape_sequence escape_sequence string_end identifier expression_statement assignment identifier subscript attribute identifier identifier identifier for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier
Run the given section.
def _contigs_dict_to_file(self, contigs, fname): f = pyfastaq.utils.open_file_write(fname) for contig in sorted(contigs, key=lambda x:len(contigs[x]), reverse=True): print(contigs[contig], file=f) pyfastaq.utils.close(f)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier for_statement identifier call identifier argument_list identifier keyword_argument identifier lambda lambda_parameters identifier call identifier argument_list subscript identifier identifier keyword_argument identifier true block expression_statement call identifier argument_list subscript identifier identifier keyword_argument identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Writes dictionary of contigs to file
def disconnect(self, driver): self.log("SSH disconnect") try: self.device.ctrl.sendline('\x03') self.device.ctrl.sendline('\x04') except OSError: self.log("Protocol already disconnected")
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end try_statement block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content escape_sequence string_end expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content escape_sequence string_end except_clause identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end
Disconnect using the protocol specific method.
def register(): registry = { key: bake_html(key) for key in ('css', 'css-all', 'tag', 'text') } registry['xpath'] = bake_parametrized(xpath_selector, select_all=False) registry['xpath-all'] = bake_parametrized(xpath_selector, select_all=True) return registry
module function_definition identifier parameters block expression_statement assignment identifier dictionary_comprehension pair identifier call identifier argument_list identifier for_in_clause identifier tuple string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list identifier keyword_argument identifier false expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list identifier keyword_argument identifier true return_statement identifier
Return dictionary of tranform factories
def _validate_args(env, args): if all([args['cpu'], args['flavor']]): raise exceptions.ArgumentError( '[-c | --cpu] not allowed with [-f | --flavor]') if all([args['memory'], args['flavor']]): raise exceptions.ArgumentError( '[-m | --memory] not allowed with [-f | --flavor]') if all([args['dedicated'], args['flavor']]): raise exceptions.ArgumentError( '[-d | --dedicated] not allowed with [-f | --flavor]') if all([args['host_id'], args['flavor']]): raise exceptions.ArgumentError( '[-h | --host-id] not allowed with [-f | --flavor]') if all([args['userdata'], args['userfile']]): raise exceptions.ArgumentError( '[-u | --userdata] not allowed with [-F | --userfile]') image_args = [args['os'], args['image']] if all(image_args): raise exceptions.ArgumentError( '[-o | --os] not allowed with [--image]') while not any([args['os'], args['image']]): args['os'] = env.input("Operating System Code", default="", show_default=False) if not args['os']: args['image'] = env.input("Image", default="", show_default=False)
module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end block raise_statement call attribute identifier identifier argument_list string string_start string_content string_end if_statement call identifier argument_list list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end block raise_statement call attribute identifier identifier argument_list string string_start string_content string_end if_statement call identifier argument_list list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end block raise_statement call attribute identifier identifier argument_list string string_start string_content string_end if_statement call identifier argument_list list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end block raise_statement call attribute identifier identifier argument_list string string_start string_content string_end if_statement call identifier argument_list list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end block raise_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end if_statement call identifier argument_list identifier block raise_statement call attribute identifier identifier argument_list string string_start string_content string_end while_statement not_operator call identifier argument_list list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end 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 keyword_argument identifier string string_start string_end keyword_argument identifier false if_statement not_operator subscript identifier string string_start string_content string_end 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 keyword_argument identifier string string_start string_end keyword_argument identifier false
Raises an ArgumentError if the given arguments are not valid.
def convert_items(self, items): return ((key, self.convert(value, self)) for key, value in items)
module function_definition identifier parameters identifier identifier block return_statement generator_expression tuple identifier call attribute identifier identifier argument_list identifier identifier for_in_clause pattern_list identifier identifier identifier
Generator like `convert_iterable`, but for 2-tuple iterators.
def value(self): if len(self._element): var = ''.join(map(str, self.trigger.agentml.parse_tags(self._element, self.trigger))) else: var = self._element.text or attribute(self._element, 'name') default = attribute(self._element, 'default') try: self._log.debug('Retrieving {type} variable {var}'.format(type=self.type, var=var)) if self.type == 'user': return self.trigger.user.get_var(var) else: return self.trigger.agentml.get_var(var) except VarNotDefinedError: if default: self._log.info('{type} variable {var} not set, returning default: {default}' .format(type=self.type.capitalize(), var=var, default=default)) self._log.info('{type} variable {var} not set and no default value has been specified' .format(type=self.type.capitalize(), var=var)) return ''
module function_definition identifier parameters identifier block if_statement call identifier argument_list attribute identifier identifier block expression_statement assignment identifier call attribute string string_start string_end identifier argument_list call identifier argument_list identifier call attribute attribute attribute identifier identifier identifier identifier argument_list attribute identifier identifier attribute identifier identifier else_clause block expression_statement assignment identifier boolean_operator attribute attribute identifier identifier identifier call identifier argument_list attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list attribute identifier identifier string string_start string_content string_end try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block return_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier else_clause block return_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier except_clause identifier block if_statement identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier return_statement string string_start string_end
Return the current value of a variable
def plotly_class(name=None, slug=None, da=None, prefix=None, postfix=None, template_type=None): 'Return a string of space-separated class names' da, app = _locate_daapp(name, slug, da) return app.extra_html_properties(prefix=prefix, postfix=postfix, template_type=template_type)
module function_definition identifier parameters default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none block expression_statement string string_start string_content string_end expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier identifier identifier return_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
Return a string of space-separated class names
def view_graph(graph_str, dest_file=None): from rez.system import system from rez.config import config if (system.platform == "linux") and (not os.getenv("DISPLAY")): print >> sys.stderr, "Unable to open display." sys.exit(1) dest_file = _write_graph(graph_str, dest_file=dest_file) viewed = False prog = config.image_viewer or 'browser' print "loading image viewer (%s)..." % prog if config.image_viewer: proc = popen([config.image_viewer, dest_file]) proc.wait() viewed = not bool(proc.returncode) if not viewed: import webbrowser webbrowser.open_new("file://" + dest_file)
module function_definition identifier parameters identifier default_parameter identifier none block import_from_statement dotted_name identifier identifier dotted_name identifier import_from_statement dotted_name identifier identifier dotted_name identifier if_statement boolean_operator parenthesized_expression comparison_operator attribute identifier identifier string string_start string_content string_end parenthesized_expression not_operator call attribute identifier identifier argument_list string string_start string_content string_end block print_statement chevron attribute identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list integer expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier expression_statement assignment identifier false expression_statement assignment identifier boolean_operator attribute identifier identifier string string_start string_content string_end print_statement binary_operator string string_start string_content string_end identifier if_statement attribute identifier identifier block expression_statement assignment identifier call identifier argument_list list attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier not_operator call identifier argument_list attribute identifier identifier if_statement not_operator identifier block import_statement dotted_name identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier
View a dot graph in an image viewer.
def toProtocolElement(self): readGroupSet = protocol.ReadGroupSet() readGroupSet.id = self.getId() readGroupSet.read_groups.extend( [readGroup.toProtocolElement() for readGroup in self.getReadGroups()] ) readGroupSet.name = self.getLocalId() readGroupSet.dataset_id = self.getParentContainer().getId() readGroupSet.stats.CopyFrom(self.getStats()) self.serializeAttributes(readGroupSet) return readGroupSet
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list list_comprehension call attribute identifier identifier argument_list for_in_clause identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute call attribute identifier identifier argument_list identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Returns the GA4GH protocol representation of this ReadGroupSet.
def chk_goids(goids, msg=None, raise_except=True): for goid in goids: if not goid_is_valid(goid): if raise_except: raise RuntimeError("BAD GO({GO}): {MSG}".format(GO=goid, MSG=msg)) else: return goid
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier true block for_statement identifier identifier block if_statement not_operator call identifier argument_list identifier block if_statement identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier else_clause block return_statement identifier
check that all GO IDs have the proper format.
def destroyTempFiles(self): os.system("rm -rf %s" % self.rootDir) logger.debug("Temp files created: %s, temp files actively destroyed: %s" % (self.tempFilesCreated, self.tempFilesDestroyed))
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple attribute identifier identifier attribute identifier identifier
Destroys all temp temp file hierarchy, getting rid of all files.
def _iso_info(iso_year, iso_week): "Give all the iso info we need from one calculation" prev_year_start = _iso_year_start(iso_year-1) year_start = _iso_year_start(iso_year) next_year_start = _iso_year_start(iso_year+1) first_day = year_start + dt.timedelta(weeks=iso_week-1) last_day = first_day + dt.timedelta(days=6) prev_year_num_weeks = ((year_start - prev_year_start).days) // 7 year_num_weeks = ((next_year_start - year_start).days) // 7 return (first_day, last_day, prev_year_num_weeks, year_num_weeks)
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier call identifier argument_list binary_operator identifier integer expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list binary_operator identifier integer expression_statement assignment identifier binary_operator identifier call attribute identifier identifier argument_list keyword_argument identifier binary_operator identifier integer expression_statement assignment identifier binary_operator identifier call attribute identifier identifier argument_list keyword_argument identifier integer expression_statement assignment identifier binary_operator parenthesized_expression attribute parenthesized_expression binary_operator identifier identifier identifier integer expression_statement assignment identifier binary_operator parenthesized_expression attribute parenthesized_expression binary_operator identifier identifier identifier integer return_statement tuple identifier identifier identifier identifier
Give all the iso info we need from one calculation
def broker_url(self): return 'amqp://{}:{}@{}/{}'.format( self.user, self.password, self.name, self.vhost)
module function_definition identifier parameters identifier block return_statement call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier
Returns a "broker URL" for use with Celery.
def normalize_arxiv(obj): obj = obj.split()[0] matched_arxiv_pre = RE_ARXIV_PRE_2007_CLASS.match(obj) if matched_arxiv_pre: return ('/'.join(matched_arxiv_pre.group("extraidentifier", "identifier"))).lower() matched_arxiv_post = RE_ARXIV_POST_2007_CLASS.match(obj) if matched_arxiv_post: return matched_arxiv_post.group("identifier") return None
module function_definition identifier parameters identifier block expression_statement assignment identifier subscript call attribute identifier identifier argument_list integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement identifier block return_statement call attribute parenthesized_expression call attribute string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement identifier block return_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement none
Return a normalized arXiv identifier from ``obj``.
def acquisition_function(self, x): return self._penalized_acquisition(x, self.model, self.X_batch, self.r_x0, self.s_x0)
module function_definition identifier parameters identifier identifier block return_statement call attribute identifier identifier argument_list identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier
Returns the value of the acquisition function at x.
def save_map(self, map_path, map_data): return self._client.send(save_map=sc_pb.RequestSaveMap( map_path=map_path, map_data=map_data))
module function_definition identifier parameters identifier identifier identifier block return_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier
Save a map into temp dir so create game can access it in multiplayer.
def getRejectionReasonsItems(self): reasons = self.getRejectionReasons() if not reasons: return [] reasons = reasons[0] keys = filter(lambda key: key != "checkbox", reasons.keys()) return map(lambda key: reasons[key], sorted(keys)) or []
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement not_operator identifier block return_statement list expression_statement assignment identifier subscript identifier integer expression_statement assignment identifier call identifier argument_list lambda lambda_parameters identifier comparison_operator identifier string string_start string_content string_end call attribute identifier identifier argument_list return_statement boolean_operator call identifier argument_list lambda lambda_parameters identifier subscript identifier identifier call identifier argument_list identifier list
Return the list of predefined rejection reasons
def schemaSetValidOptions(self, options): ret = libxml2mod.xmlSchemaSetValidOptions(self._o, options) return ret
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier identifier return_statement identifier
Sets the options to be used during the validation.
def account(self, key=None, address=None, name=None): if key: return self.client.account(key, wallet=self) if address: q = dict(address=address) elif name: q = dict(name=name) else: raise TypeError("Missing param: key, address, or name is required.") return Account( self.resource.account_query(q).get(), self.client, wallet=self)
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none block if_statement identifier block return_statement call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier identifier if_statement identifier block expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier elif_clause identifier block expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier else_clause block raise_statement call identifier argument_list string string_start string_content string_end return_statement call identifier argument_list call attribute call attribute attribute identifier identifier identifier argument_list identifier identifier argument_list attribute identifier identifier keyword_argument identifier identifier
Query for an account by key, address, or name.
def parsePositionFile(filename): l=[] with open( filename, "rb" ) as theFile: reader = csv.DictReader( theFile ) for line in reader: mytime=dateparser.parse(line['time']) line['strtime']=mytime.strftime("%d %b %Y, %H:%M UTC") l.append(line) return l
module function_definition identifier parameters identifier block expression_statement assignment identifier list with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end 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 expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Parses Android GPS logger csv file and returns list of dictionaries
def searchlog(self, argv): opts = cmdline(argv, FLAGS_SEARCHLOG) self.foreach(opts.args, lambda job: output(job.searchlog(**opts.kwargs)))
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier lambda lambda_parameters identifier call identifier argument_list call attribute identifier identifier argument_list dictionary_splat attribute identifier identifier
Retrieve the searchlog for the specified search jobs.
def _convert_value_to_native(value): if isinstance(value, Counter32): return int(value.prettyPrint()) if isinstance(value, Counter64): return int(value.prettyPrint()) if isinstance(value, Gauge32): return int(value.prettyPrint()) if isinstance(value, Integer): return int(value.prettyPrint()) if isinstance(value, Integer32): return int(value.prettyPrint()) if isinstance(value, Unsigned32): return int(value.prettyPrint()) if isinstance(value, IpAddress): return str(value.prettyPrint()) if isinstance(value, OctetString): try: return value.asOctets().decode(value.encoding) except UnicodeDecodeError: return value.asOctets() if isinstance(value, TimeTicks): return timedelta(seconds=int(value.prettyPrint()) / 100.0) return value
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier identifier block return_statement call identifier argument_list call attribute identifier identifier argument_list if_statement call identifier argument_list identifier identifier block return_statement call identifier argument_list call attribute identifier identifier argument_list if_statement call identifier argument_list identifier identifier block return_statement call identifier argument_list call attribute identifier identifier argument_list if_statement call identifier argument_list identifier identifier block return_statement call identifier argument_list call attribute identifier identifier argument_list if_statement call identifier argument_list identifier identifier block return_statement call identifier argument_list call attribute identifier identifier argument_list if_statement call identifier argument_list identifier identifier block return_statement call identifier argument_list call attribute identifier identifier argument_list if_statement call identifier argument_list identifier identifier block return_statement call identifier argument_list call attribute identifier identifier argument_list if_statement call identifier argument_list identifier identifier block try_statement block return_statement call attribute call attribute identifier identifier argument_list identifier argument_list attribute identifier identifier except_clause identifier block return_statement call attribute identifier identifier argument_list if_statement call identifier argument_list identifier identifier block return_statement call identifier argument_list keyword_argument identifier binary_operator call identifier argument_list call attribute identifier identifier argument_list float return_statement identifier
Converts pysnmp objects into native Python objects.
def receive_message(self): with self.lock: assert self.can_receive_messages() message_type = self._read_message_type(self._file) message = message_type(self._file, self) self._message_received(message)
module function_definition identifier parameters identifier block with_statement with_clause with_item attribute identifier identifier block assert_statement call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier
Receive a message from the file.
def delete(self): if not HAS_SQL: return try: conn, c = self.connect() c.execute('DELETE FROM {0}'.format(self.table_name)) conn.commit() conn.close() except: log.traceback(logging.DEBUG)
module function_definition identifier parameters identifier block if_statement not_operator identifier block return_statement try_statement block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list except_clause block expression_statement call attribute identifier identifier argument_list attribute identifier identifier
Clears all cached Session objects.
def outlays(self): return pd.DataFrame({x.name: x.outlays for x in self.securities})
module function_definition identifier parameters identifier block return_statement call attribute identifier identifier argument_list dictionary_comprehension pair attribute identifier identifier attribute identifier identifier for_in_clause identifier attribute identifier identifier
Returns a DataFrame of outlays for each child SecurityBase
def make_form_or_formset_fields_not_required(form_or_formset): if isinstance(form_or_formset, BaseFormSet): for single_form in form_or_formset: make_form_fields_not_required(single_form) else: make_form_fields_not_required(form_or_formset)
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier identifier block for_statement identifier identifier block expression_statement call identifier argument_list identifier else_clause block expression_statement call identifier argument_list identifier
Take a Form or FormSet and set all fields to not required.
def _set_flow_entry(self, datapath, actions, in_port, dst, src=None): set_flow = self._set_flow_func.get(datapath.ofproto.OFP_VERSION) assert set_flow set_flow(datapath, actions, in_port, dst, src)
module function_definition identifier parameters identifier identifier identifier identifier identifier default_parameter identifier none block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier assert_statement identifier expression_statement call identifier argument_list identifier identifier identifier identifier identifier
set a flow entry.
def action_print(reader, *args): arg_count = len(args) if arg_count == 0: stop_after = 0 elif arg_count == 1: stop_after = int(args[0]) else: raise RuntimeError("0 or 1 arguments expected for action 'print'") for i, record in enumerate(reader, 1): print(record.to_message()) if i == stop_after: break
module function_definition identifier parameters identifier list_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier integer block expression_statement assignment identifier integer elif_clause comparison_operator identifier integer block expression_statement assignment identifier call identifier argument_list subscript identifier integer else_clause block raise_statement call identifier argument_list string string_start string_content string_end for_statement pattern_list identifier identifier call identifier argument_list identifier integer block expression_statement call identifier argument_list call attribute identifier identifier argument_list if_statement comparison_operator identifier identifier block break_statement
Simply print the Flow Log records to output.
def sis_metadata(self): if not self.is_sis: return None tags = self.pages[0].tags result = {} try: result.update(tags['OlympusINI'].value) except Exception: pass try: result.update(tags['OlympusSIS'].value) except Exception: pass return result
module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block return_statement none expression_statement assignment identifier attribute subscript attribute identifier identifier integer identifier expression_statement assignment identifier dictionary try_statement block expression_statement call attribute identifier identifier argument_list attribute subscript identifier string string_start string_content string_end identifier except_clause identifier block pass_statement try_statement block expression_statement call attribute identifier identifier argument_list attribute subscript identifier string string_start string_content string_end identifier except_clause identifier block pass_statement return_statement identifier
Return Olympus SIS metadata from SIS and INI tags as dict.
def deploy(self, fobj, md5=None, sha1=None, parameters={}): return self._accessor.deploy(self, fobj, md5, sha1, parameters)
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier dictionary block return_statement call attribute attribute identifier identifier identifier argument_list identifier identifier identifier identifier identifier
Upload the given file object to this path
def stderr_avail(self): data = self.interpreter.stderr_write.empty_queue() if data: self.write(data, error=True) self.flush(error=True)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier true expression_statement call attribute identifier identifier argument_list keyword_argument identifier true
Data is available in stderr, let's empty the queue and write it!
def _add_token_to_document(self, token_string, token_attrs=None): token_feat = {self.ns+':token': token_string} if token_attrs: token_attrs.update(token_feat) else: token_attrs = token_feat token_id = 'token_{}'.format(self.token_count) self.add_node(token_id, layers={self.ns, self.ns+':token'}, attr_dict=token_attrs) self.token_count += 1 self.tokens.append(token_id) return token_id
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment identifier dictionary pair binary_operator attribute identifier identifier string string_start string_content string_end identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement assignment identifier identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier set attribute identifier identifier binary_operator attribute identifier identifier string string_start string_content string_end keyword_argument identifier identifier expression_statement augmented_assignment attribute identifier identifier integer expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement identifier
add a token node to this document graph
def ProcessContent(self, strip_expansion=False): self._ParseFile() if strip_expansion: collection = None else: collection = MacroCollection() for section in self._sections: section.BindMacroCollection(collection) result = '' for section in self._sections: result += section.text self._processed_content = result
module function_definition identifier parameters identifier default_parameter identifier false block expression_statement call attribute identifier identifier argument_list if_statement identifier block expression_statement assignment identifier none else_clause block expression_statement assignment identifier call identifier argument_list for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier string string_start string_end for_statement identifier attribute identifier identifier block expression_statement augmented_assignment identifier attribute identifier identifier expression_statement assignment attribute identifier identifier identifier
Processes the file contents.
def ansi(string, *args): ansi = '' for arg in args: arg = str(arg) if not re.match(ANSI_PATTERN, arg): raise ValueError('Additional arguments must be ansi strings') ansi += arg return ansi + string + colorama.Style.RESET_ALL
module function_definition identifier parameters identifier list_splat_pattern identifier block expression_statement assignment identifier string string_start string_end for_statement identifier identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement not_operator call attribute identifier identifier argument_list identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement augmented_assignment identifier identifier return_statement binary_operator binary_operator identifier identifier attribute attribute identifier identifier identifier
Convenience function to chain multiple ColorWrappers to a string
def search(self, query: Optional[dict] = None, offset: Optional[int] = None, limit: Optional[int] = None, order_by: Union[None, list, tuple] = None) -> Sequence['IModel']: raise NotImplementedError
module function_definition identifier parameters identifier typed_default_parameter identifier type generic_type identifier type_parameter type identifier none typed_default_parameter identifier type generic_type identifier type_parameter type identifier none typed_default_parameter identifier type generic_type identifier type_parameter type identifier none typed_default_parameter identifier type generic_type identifier type_parameter type none type identifier type identifier none type generic_type identifier type_parameter type string string_start string_content string_end block raise_statement identifier
return search result based on specified rulez query
def count(self): self.request_params.update({'sysparm_count': True}) response = self.session.get(self._get_stats_url(), params=self._get_formatted_query(fields=list(), limit=None, order_by=list(), offset=None)) content = self._get_content(response) return int(content['stats']['count'])
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list dictionary pair string string_start string_content string_end true expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list keyword_argument identifier call identifier argument_list keyword_argument identifier none keyword_argument identifier call identifier argument_list keyword_argument identifier none expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement call identifier argument_list subscript subscript identifier string string_start string_content string_end string string_start string_content string_end
Returns the number of records the query would yield
def partition(lst, n): q, r = divmod(len(lst), n) indices = [q*i + min(i, r) for i in xrange(n+1)] return [lst[indices[i]:indices[i+1]] for i in xrange(n)], \ [list(xrange(indices[i], indices[i+1])) for i in xrange(n)]
module function_definition identifier parameters identifier identifier block expression_statement assignment pattern_list identifier identifier call identifier argument_list call identifier argument_list identifier identifier expression_statement assignment identifier list_comprehension binary_operator binary_operator identifier identifier call identifier argument_list identifier identifier for_in_clause identifier call identifier argument_list binary_operator identifier integer return_statement expression_list list_comprehension subscript identifier slice subscript identifier identifier subscript identifier binary_operator identifier integer for_in_clause identifier call identifier argument_list identifier line_continuation list_comprehension call identifier argument_list call identifier argument_list subscript identifier identifier subscript identifier binary_operator identifier integer for_in_clause identifier call identifier argument_list identifier
Divide list into n equal parts
def update_hash_prefix_cache(self): try: self.storage.cleanup_full_hashes() self.storage.commit() self._sync_threat_lists() self.storage.commit() self._sync_hash_prefix_cache() except Exception: self.storage.rollback() raise
module function_definition identifier parameters identifier block try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list except_clause identifier block expression_statement call attribute attribute identifier identifier identifier argument_list raise_statement
Update locally cached threat lists.
def register_token_getter(self, provider): app = oauth.remote_apps[provider] decorator = getattr(app, 'tokengetter') def getter(token=None): return self.token_getter(provider, token) decorator(getter)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end function_definition identifier parameters default_parameter identifier none block return_statement call attribute identifier identifier argument_list identifier identifier expression_statement call identifier argument_list identifier
Register callback to retrieve token from session
def away_abbreviation(self): abbr = re.sub(r'.*/teams/', '', str(self._away_name)) abbr = re.sub(r'/.*', '', abbr) return abbr
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end call identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end identifier return_statement identifier
Returns a ``string`` of the away team's abbreviation, such as 'NWE'.
def reduce_fit(interface, state, label, inp): import numpy as np out = interface.output(0) sum_etde = 0 sum_ete = [0 for _ in range(len(state["X_indices"]) + 1)] for key, value in inp: if key == "etde": sum_etde += value else: sum_ete[key] += value sum_ete += np.true_divide(np.eye(len(sum_ete)), state["nu"]) out.add("params", np.linalg.lstsq(sum_ete, sum_etde)[0])
module function_definition identifier parameters identifier identifier identifier identifier block import_statement aliased_import dotted_name identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list integer expression_statement assignment identifier integer expression_statement assignment identifier list_comprehension integer for_in_clause identifier call identifier argument_list binary_operator call identifier argument_list subscript identifier string string_start string_content string_end integer for_statement pattern_list identifier identifier identifier block if_statement comparison_operator identifier string string_start string_content string_end block expression_statement augmented_assignment identifier identifier else_clause block expression_statement augmented_assignment subscript identifier identifier identifier expression_statement augmented_assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list call identifier argument_list identifier subscript identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end subscript call attribute attribute identifier identifier identifier argument_list identifier identifier integer
Function joins all partially calculated matrices ETE and ETDe, aggregates them and it calculates final parameters.
def namedObject(name): classSplit = name.split('.') module = namedModule('.'.join(classSplit[:-1])) return getattr(module, classSplit[-1])
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list call attribute string string_start string_content string_end identifier argument_list subscript identifier slice unary_operator integer return_statement call identifier argument_list identifier subscript identifier unary_operator integer
Get a fully named module-global object.
def _initialize_trackbars(self): for parameter in self.block_matcher.parameter_maxima.keys(): maximum = self.block_matcher.parameter_maxima[parameter] if not maximum: maximum = self.shortest_dimension cv2.createTrackbar(parameter, self.window_name, self.block_matcher.__getattribute__(parameter), maximum, partial(self._set_value, parameter))
module function_definition identifier parameters identifier block for_statement identifier call attribute attribute attribute identifier identifier identifier identifier argument_list block expression_statement assignment identifier subscript attribute attribute identifier identifier identifier identifier if_statement not_operator identifier block expression_statement assignment identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier call attribute attribute identifier identifier identifier argument_list identifier identifier call identifier argument_list attribute identifier identifier identifier
Initialize trackbars by discovering ``block_matcher``'s parameters.
def make_emoji_dict(self): emoji_dict = {} for line in self.emoji_full_filepath.split('\n'): (emoji, description) = line.strip().split('\t')[0:2] emoji_dict[emoji] = description return emoji_dict
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary for_statement identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content escape_sequence string_end block expression_statement assignment tuple_pattern identifier identifier subscript call attribute call attribute identifier identifier argument_list identifier argument_list string string_start string_content escape_sequence string_end slice integer integer expression_statement assignment subscript identifier identifier identifier return_statement identifier
Convert emoji lexicon file to a dictionary
def iname(self) -> InstanceName: dp = self.data_parent() return (self.name if dp and self.ns == dp.ns else self.ns + ":" + self.name)
module function_definition identifier parameters identifier type identifier block expression_statement assignment identifier call attribute identifier identifier argument_list return_statement parenthesized_expression conditional_expression attribute identifier identifier boolean_operator identifier comparison_operator attribute identifier identifier attribute identifier identifier binary_operator binary_operator attribute identifier identifier string string_start string_content string_end attribute identifier identifier
Return the instance name corresponding to the receiver.
def prep_input(self, read_list): logger.info("Prepping input.") i = 0 for content in read_list: quality_issue = self._check_content(content.get_text()) if quality_issue is not None: logger.warning("Skipping %d due to: %s" % (content.get_id(), quality_issue)) continue cid = content.get_id() if isinstance(cid, str) and re.match('^\w*?\d+$', cid) is None: new_id = 'FILE%06d' % i i += 1 self.id_maps[new_id] = cid content.change_id(new_id) new_fpath = content.copy_to(self.input_dir) else: new_fpath = content.copy_to(self.input_dir) self.num_input += 1 logger.debug('%s saved for reading by reach.' % new_fpath) return
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier integer for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list if_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple call attribute identifier identifier argument_list identifier continue_statement expression_statement assignment identifier call attribute identifier identifier argument_list if_statement boolean_operator call identifier argument_list identifier identifier comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end identifier none block expression_statement assignment identifier binary_operator string string_start string_content string_end identifier expression_statement augmented_assignment identifier integer expression_statement assignment subscript attribute identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement augmented_assignment attribute identifier identifier integer expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier return_statement
Apply the readers to the content.
def color_greedy(self): n = self.num_vertices() coloring = np.zeros(n, dtype=int) for i, nbrs in enumerate(self.adj_list()): nbr_colors = set(coloring[nbrs]) for c in count(1): if c not in nbr_colors: coloring[i] = c break return coloring
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier for_statement pattern_list identifier identifier call identifier argument_list call attribute identifier identifier argument_list block expression_statement assignment identifier call identifier argument_list subscript identifier identifier for_statement identifier call identifier argument_list integer block if_statement comparison_operator identifier identifier block expression_statement assignment subscript identifier identifier identifier break_statement return_statement identifier
Returns a greedy vertex coloring as an array of ints.
def raw_diff(self): udiff_copy = self.copy_iterator() if self.__format == 'gitdiff': udiff_copy = self._parse_gitdiff(udiff_copy) return u''.join(udiff_copy)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement call attribute string string_start string_end identifier argument_list identifier
Returns raw string as udiff
def download_file(fName, time, dire=pDir()): gen_hash = get_hash(fName, 64, dire) if gen_hash == -1: return -1 user_agent = {'User-agent': 'SubDB/1.0 (sub/0.1; http://github.com/leosartaj/sub)'} param = {'action': 'download', 'hash': gen_hash, 'language': 'en'} try: r = requests.get("http://api.thesubdb.com/", headers = user_agent, params = param, timeout=time) except (requests.exceptions.Timeout, socket.error): return 'Timeout Error' if r.status_code != 200: return r.status_code fName, fExt = os.path.splitext(fName) fName += '.srt' fName = os.path.join(dire, fName) with open(fName, 'wb') as f: f.write(r.text.encode('ascii', 'ignore')) return r.status_code
module function_definition identifier parameters identifier identifier default_parameter identifier call identifier argument_list block expression_statement assignment identifier call identifier argument_list identifier integer identifier if_statement comparison_operator identifier unary_operator integer block return_statement unary_operator integer expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end identifier pair string string_start string_content string_end string string_start string_content string_end try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier except_clause tuple attribute attribute identifier identifier identifier attribute identifier identifier block return_statement string string_start string_content string_end if_statement comparison_operator attribute identifier identifier integer block return_statement attribute identifier identifier expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement augmented_assignment identifier string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list 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 call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end return_statement attribute identifier identifier
download the required subtitle
def to_xdr_object(self): return Xdr.types.Memo(type=Xdr.const.MEMO_TEXT, text=self.text)
module function_definition identifier parameters identifier block return_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier attribute identifier identifier
Creates an XDR Memo object for a transaction with MEMO_TEXT.
def job_started_message(self, job, queue): return '[%s|%s|%s] starting' % (queue._cached_name, job.pk.get(), job._cached_identifier)
module function_definition identifier parameters identifier identifier identifier block return_statement binary_operator string string_start string_content string_end tuple attribute identifier identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier
Return the message to log just befre the execution of the job
def admin_password(self, environment, target_name, password): try: remote_server_command( ["ssh", environment.deploy_target, "admin_password", target_name, password], environment, self, clean_up=True ) return True except WebCommandError: return False
module function_definition identifier parameters identifier identifier identifier identifier block try_statement block expression_statement call identifier argument_list list string string_start string_content string_end attribute identifier identifier string string_start string_content string_end identifier identifier identifier identifier keyword_argument identifier true return_statement true except_clause identifier block return_statement false
Return True if password was set successfully
def to_dict(self): 'Convert a structure into a Python native type.' ctx = Context() ContextFlags = self.ContextFlags ctx['ContextFlags'] = ContextFlags if (ContextFlags & CONTEXT_DEBUG_REGISTERS) == CONTEXT_DEBUG_REGISTERS: for key in self._ctx_debug: ctx[key] = getattr(self, key) if (ContextFlags & CONTEXT_FLOATING_POINT) == CONTEXT_FLOATING_POINT: ctx['FloatSave'] = self.FloatSave.to_dict() if (ContextFlags & CONTEXT_SEGMENTS) == CONTEXT_SEGMENTS: for key in self._ctx_segs: ctx[key] = getattr(self, key) if (ContextFlags & CONTEXT_INTEGER) == CONTEXT_INTEGER: for key in self._ctx_int: ctx[key] = getattr(self, key) if (ContextFlags & CONTEXT_CONTROL) == CONTEXT_CONTROL: for key in self._ctx_ctrl: ctx[key] = getattr(self, key) if (ContextFlags & CONTEXT_EXTENDED_REGISTERS) == CONTEXT_EXTENDED_REGISTERS: er = [ self.ExtendedRegisters[index] for index in compat.xrange(0, MAXIMUM_SUPPORTED_EXTENSION) ] er = tuple(er) ctx['ExtendedRegisters'] = er return ctx
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier attribute identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier if_statement comparison_operator parenthesized_expression binary_operator identifier identifier identifier block for_statement identifier attribute identifier identifier block expression_statement assignment subscript identifier identifier call identifier argument_list identifier identifier if_statement comparison_operator parenthesized_expression binary_operator identifier identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list if_statement comparison_operator parenthesized_expression binary_operator identifier identifier identifier block for_statement identifier attribute identifier identifier block expression_statement assignment subscript identifier identifier call identifier argument_list identifier identifier if_statement comparison_operator parenthesized_expression binary_operator identifier identifier identifier block for_statement identifier attribute identifier identifier block expression_statement assignment subscript identifier identifier call identifier argument_list identifier identifier if_statement comparison_operator parenthesized_expression binary_operator identifier identifier identifier block for_statement identifier attribute identifier identifier block expression_statement assignment subscript identifier identifier call identifier argument_list identifier identifier if_statement comparison_operator parenthesized_expression binary_operator identifier identifier identifier block expression_statement assignment identifier list_comprehension subscript attribute identifier identifier identifier for_in_clause identifier call attribute identifier identifier argument_list integer identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier return_statement identifier
Convert a structure into a Python native type.
def execute_once(self): symbol = self.tape.get(self.head, self.EMPTY_SYMBOL) index = self.alphabet.index(symbol) rule = self.states[self.state][index] if rule is None: raise RuntimeError('Unexpected symbol: ' + symbol) self.tape[self.head] = rule[0] if rule[1] == 'L': self.head -= 1 elif rule[1] == 'R': self.head += 1 self.state = rule[2]
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier subscript subscript attribute identifier identifier attribute identifier identifier identifier if_statement comparison_operator identifier none block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement assignment subscript attribute identifier identifier attribute identifier identifier subscript identifier integer if_statement comparison_operator subscript identifier integer string string_start string_content string_end block expression_statement augmented_assignment attribute identifier identifier integer elif_clause comparison_operator subscript identifier integer string string_start string_content string_end block expression_statement augmented_assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier subscript identifier integer
One step of execution.
def hostname(self): try: return self.data.get('identity').get('host_name') except (KeyError, AttributeError): return self.device_status_simple('')
module function_definition identifier parameters identifier block try_statement block return_statement call attribute call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier argument_list string string_start string_content string_end except_clause tuple identifier identifier block return_statement call attribute identifier identifier argument_list string string_start string_end
Return the hostname of the printer.
def _parse_arg(func, variables, arg_name, anno): if isinstance(anno, str): var = variables[anno] return var, var.read_latest elif (isinstance(anno, list) and len(anno) == 1 and isinstance(anno[0], str)): var = variables[anno[0]] return var, var.read_all raise StartupError( 'cannot parse annotation %r of parameter %r for %r' % (anno, arg_name, func))
module function_definition identifier parameters identifier identifier identifier identifier block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier subscript identifier identifier return_statement expression_list identifier attribute identifier identifier elif_clause parenthesized_expression boolean_operator boolean_operator call identifier argument_list identifier identifier comparison_operator call identifier argument_list identifier integer call identifier argument_list subscript identifier integer identifier block expression_statement assignment identifier subscript identifier subscript identifier integer return_statement expression_list identifier attribute identifier identifier raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier identifier
Parse an argument's annotation.
def on_headers(self, response, exc=None): if response.status_code == 101: connection = response.connection request = response.request handler = request.websocket_handler if not handler: handler = WS() parser = request.client.frame_parser(kind=1) consumer = partial(WebSocketClient.create, response, handler, parser) connection.upgrade(consumer) response.event('post_request').fire() websocket = connection.current_consumer() response.request_again = lambda r: websocket
module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement comparison_operator attribute identifier identifier integer block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier if_statement not_operator identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier integer expression_statement assignment identifier call identifier argument_list attribute identifier identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute call attribute identifier identifier argument_list string string_start string_content string_end identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier lambda lambda_parameters identifier identifier
Websocket upgrade as ``on_headers`` event.
def _log_thread(self, pipe, queue): def enqueue_output(out, q): for line in iter(out.readline, b''): q.put(line.rstrip()) out.close() t = threading.Thread(target=enqueue_output, args=(pipe, queue)) t.daemon = True t.start() self.threads.append(t)
module function_definition identifier parameters identifier identifier identifier block function_definition identifier parameters identifier identifier block for_statement identifier call identifier argument_list attribute identifier identifier string string_start string_end block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier tuple identifier identifier expression_statement assignment attribute identifier identifier true expression_statement call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Start a thread logging output from pipe
def contains(polygon, point): in_hole = functools.reduce( lambda P, Q: P and Q, [interior.covers(point) for interior in polygon.interiors] ) if polygon.interiors else False return polygon.covers(point) and not in_hole
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier conditional_expression call attribute identifier identifier argument_list lambda lambda_parameters identifier identifier boolean_operator identifier identifier list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier attribute identifier identifier attribute identifier identifier false return_statement boolean_operator call attribute identifier identifier argument_list identifier not_operator identifier
Tests whether point lies within the polygon
def on_complete(cls, req): if not (req.status == 200 or req.status == 0): alert("Couldn't connect to authority base.") LogView.add( "Error when calling Aleph authority base: %s" % req.text ) AuthorBar.hide() return AuthorBar.hide() cls.set_select(json.loads(req.text))
module function_definition identifier parameters identifier identifier block if_statement not_operator parenthesized_expression boolean_operator comparison_operator attribute identifier identifier integer comparison_operator attribute identifier identifier integer block expression_statement call identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier expression_statement call attribute identifier identifier argument_list return_statement expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier
Callback called when the request was received.
def fetch_last_receipt_number(self, point_of_sales, receipt_type): client = clients.get_client('wsfe', point_of_sales.owner.is_sandboxed) response_xml = client.service.FECompUltimoAutorizado( serializers.serialize_ticket( point_of_sales.owner.get_or_create_ticket('wsfe') ), point_of_sales.number, receipt_type.code, ) check_response(response_xml) return response_xml.CbteNro
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end attribute identifier identifier attribute identifier identifier expression_statement call identifier argument_list identifier return_statement attribute identifier identifier
Returns the number for the last validated receipt.
def delay(name, args, kwargs): args = args or [] kwargs = dict(k.split() for k in kwargs) if kwargs else {} if name not in celery.tasks: log.error('Job %s not found', name) job = celery.tasks[name] log.info('Sending job %s', name) async_result = job.delay(*args, **kwargs) log.info('Job %s sended to workers', async_result.id)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier boolean_operator identifier list expression_statement assignment identifier conditional_expression call identifier generator_expression call attribute identifier identifier argument_list for_in_clause identifier identifier identifier dictionary if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier subscript attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list list_splat identifier dictionary_splat identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier
Run a job asynchronously
def monitor(app): heroku_app = HerokuApp(dallinger_uid=app) webbrowser.open(heroku_app.dashboard_url) webbrowser.open("https://requester.mturk.com/mturk/manageHITs") heroku_app.open_logs() check_call(["open", heroku_app.db_uri]) while _keep_running(): summary = get_summary(app) click.clear() click.echo(header) click.echo("\nExperiment {}\n".format(app)) click.echo(summary) time.sleep(10)
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list expression_statement call identifier argument_list list string string_start string_content string_end attribute identifier identifier while_statement call identifier argument_list block expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content escape_sequence escape_sequence string_end identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list integer
Set up application monitoring.
def find_root(self): cmd = self while cmd.parent: cmd = cmd.parent return cmd
module function_definition identifier parameters identifier block expression_statement assignment identifier identifier while_statement attribute identifier identifier block expression_statement assignment identifier attribute identifier identifier return_statement identifier
Traverse parent refs to top.
async def user_info(self, params=None, **kwargs): params = params or {} params[ 'fields'] = 'id,email,first_name,last_name,name,link,locale,' \ 'gender,location' return await super(FacebookClient, self).user_info(params=params, **kwargs)
module function_definition identifier parameters identifier default_parameter identifier none dictionary_splat_pattern identifier block expression_statement assignment identifier boolean_operator identifier dictionary expression_statement assignment subscript identifier string string_start string_content string_end concatenated_string string string_start string_content string_end string string_start string_content string_end return_statement await call attribute call identifier argument_list identifier identifier identifier argument_list keyword_argument identifier identifier dictionary_splat identifier
Facebook required fields-param.
def team_profile_get(self, **kwargs) -> SlackResponse: self._validate_xoxp_token() return self.api_call("team.profile.get", http_verb="GET", params=kwargs)
module function_definition identifier parameters identifier dictionary_splat_pattern identifier type identifier block expression_statement call attribute identifier identifier argument_list return_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier identifier
Retrieve a team's profile.
def tracker(): application = mmi.tracker.app() application.listen(22222) logger.info('serving at port 22222') tornado.ioloop.IOLoop.instance().start()
module function_definition identifier parameters block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list integer expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute call attribute attribute attribute identifier identifier identifier identifier argument_list identifier argument_list
start a tracker to register running models
def until(self, regex): logger.debug('waiting for %s', regex) r = re.compile(regex, re.M) self.tn.expect([r])
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list list identifier
Wait until the regex encountered
def tables_with_counts(self): table_to_count = lambda t: self.count_rows(t) return zip(self.tables, map(table_to_count, self.tables))
module function_definition identifier parameters identifier block expression_statement assignment identifier lambda lambda_parameters identifier call attribute identifier identifier argument_list identifier return_statement call identifier argument_list attribute identifier identifier call identifier argument_list identifier attribute identifier identifier
Return the number of entries in all table.
def first_rec(ofile, Rec, file_type): keylist = [] opened = False while not opened: try: pmag_out = open(ofile, 'w') opened = True except IOError: time.sleep(1) outstring = "tab \t" + file_type + "\n" pmag_out.write(outstring) keystring = "" for key in list(Rec.keys()): keystring = keystring + '\t' + key.strip() keylist.append(key) keystring = keystring + '\n' pmag_out.write(keystring[1:]) pmag_out.close() return keylist
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier list expression_statement assignment identifier false while_statement not_operator identifier block try_statement block expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier true except_clause identifier block expression_statement call attribute identifier identifier argument_list integer expression_statement assignment identifier binary_operator binary_operator string string_start string_content escape_sequence string_end identifier string string_start string_content escape_sequence string_end expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier string string_start string_end for_statement identifier call identifier argument_list call attribute identifier identifier argument_list block expression_statement assignment identifier binary_operator binary_operator identifier string string_start string_content escape_sequence string_end call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier binary_operator identifier string string_start string_content escape_sequence string_end expression_statement call attribute identifier identifier argument_list subscript identifier slice integer expression_statement call attribute identifier identifier argument_list return_statement identifier
opens the file ofile as a magic template file with headers as the keys to Rec
async def join_voice_channel(self, guild_id, channel_id): voice_ws = self.get_voice_ws(guild_id) await voice_ws.voice_state(guild_id, channel_id)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement await call attribute identifier identifier argument_list identifier identifier
Alternative way to join a voice channel if node is known.
def urls(self, version=None): urls = [] for base_url, routes in self.api.http.routes.items(): for url, methods in routes.items(): for method, versions in methods.items(): for interface_version, interface in versions.items(): if interface_version == version and interface == self: if not url in urls: urls.append(('/v{0}'.format(version) if version else '') + url) return urls
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier list for_statement pattern_list identifier identifier call attribute attribute attribute attribute identifier identifier identifier identifier identifier argument_list block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement boolean_operator comparison_operator identifier identifier comparison_operator identifier identifier block if_statement not_operator comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator parenthesized_expression conditional_expression call attribute string string_start string_content string_end identifier argument_list identifier identifier string string_start string_end identifier return_statement identifier
Returns all URLS that are mapped to this interface
def root_tokens(self): if not self.is_tagged(ANALYSIS): self.tag_analysis() return self.get_analysis_element(ROOT_TOKENS)
module function_definition identifier parameters identifier block if_statement not_operator call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list return_statement call attribute identifier identifier argument_list identifier
Root tokens of word roots.
def gather_hinting(config, rules, valid_paths): hinting = collections.defaultdict(list) for rule in rules: root, name = rule.code_path.split(':', 1) info = valid_paths[root][name] if info['hints-callable']: result = info['hints-callable'](config=config, **rule.arguments) if rule.negated and not info['hints-invertible']: continue for key, values in result.items(): key = 'not_' + key if rule.negated else key hinting[key].extend(values) for key, value in info['datanommer-hints'].items(): if rule.negated and not info['hints-invertible']: continue key = 'not_' + key if rule.negated else key hinting[key] += value log.debug('gathered hinting %r', hinting) return hinting
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier for_statement identifier identifier block expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end integer expression_statement assignment identifier subscript subscript identifier identifier identifier if_statement subscript identifier string string_start string_content string_end block expression_statement assignment identifier call subscript identifier string string_start string_content string_end argument_list keyword_argument identifier identifier dictionary_splat attribute identifier identifier if_statement boolean_operator attribute identifier identifier not_operator subscript identifier string string_start string_content string_end block continue_statement for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement assignment identifier conditional_expression binary_operator string string_start string_content string_end identifier attribute identifier identifier identifier expression_statement call attribute subscript identifier identifier identifier argument_list identifier for_statement pattern_list identifier identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list block if_statement boolean_operator attribute identifier identifier not_operator subscript identifier string string_start string_content string_end block continue_statement expression_statement assignment identifier conditional_expression binary_operator string string_start string_content string_end identifier attribute identifier identifier identifier expression_statement augmented_assignment subscript identifier identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement identifier
Construct hint arguments for datanommer from a list of rules.
def bar_chart_mf(data, path_name): N = len(data) ind = np.arange(N) width = 0.8 fig, ax = pyplot.subplots() rects1 = ax.bar(ind, data, width, color='g') ax.set_ylabel('Population') ax.set_xticks(ind+width/2) labs = ['m='+str(i) for i in range(-N/2+1, N/2+1)] ax.set_xticklabels(labs) def autolabel(rects): for rect in rects: rect.get_height() autolabel(rects1) pyplot.savefig(path_name) pyplot.close()
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier float expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list binary_operator identifier binary_operator identifier integer expression_statement assignment identifier list_comprehension binary_operator string string_start string_content string_end call identifier argument_list identifier for_in_clause identifier call identifier argument_list binary_operator binary_operator unary_operator identifier integer integer binary_operator binary_operator identifier integer integer expression_statement call attribute identifier identifier argument_list identifier function_definition identifier parameters identifier block for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list expression_statement call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list
Make a bar chart for data on MF quantities.
def load(self, commit=None): git_info = self.record_git_info(commit) LOGGER.debug("Loading the result for commit '%s'.", git_info.hexsha) filename = self.get_filename(git_info) LOGGER.debug("Loading the result '%s'.", filename) result = super(RepoResultManager, self).load(filename) self.add_git(result.meta, git_info) return result
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call attribute call identifier argument_list identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier return_statement identifier
Load a result from the storage directory.
def save(self, filename): plt.savefig(filename, fig=self.fig, facecolor='black', edgecolor='black')
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end
save colormap to file
def _load_api(self): self._add_url_route('get_scheduler_info', '', api.get_scheduler_info, 'GET') self._add_url_route('add_job', '/jobs', api.add_job, 'POST') self._add_url_route('get_job', '/jobs/<job_id>', api.get_job, 'GET') self._add_url_route('get_jobs', '/jobs', api.get_jobs, 'GET') self._add_url_route('delete_job', '/jobs/<job_id>', api.delete_job, 'DELETE') self._add_url_route('update_job', '/jobs/<job_id>', api.update_job, 'PATCH') self._add_url_route('pause_job', '/jobs/<job_id>/pause', api.pause_job, 'POST') self._add_url_route('resume_job', '/jobs/<job_id>/resume', api.resume_job, 'POST') self._add_url_route('run_job', '/jobs/<job_id>/run', api.run_job, 'POST')
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end attribute identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end attribute identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end attribute identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end attribute identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end attribute identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end attribute identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end attribute identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end attribute identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end attribute identifier identifier string string_start string_content string_end
Add the routes for the scheduler API.
def print_packet_count(): for name in archive.list_packet_names(): packet_count = 0 for group in archive.list_packet_histogram(name): for rec in group.records: packet_count += rec.count print(' {: <40} {: >20}'.format(name, packet_count))
module function_definition identifier parameters block for_statement identifier call attribute identifier identifier argument_list block expression_statement assignment identifier integer for_statement identifier call attribute identifier identifier argument_list identifier block for_statement identifier attribute identifier identifier block expression_statement augmented_assignment identifier attribute identifier identifier expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier
Print the number of packets grouped by packet name.
def _compile(self, expression): x = self.RE_PYTHON_VAR.sub('(?:\\1,)', expression) x = self.RE_SPACES.sub('', x) return re.compile(x)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content escape_sequence string_end identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_end identifier return_statement call attribute identifier identifier argument_list identifier
Transform a class exp into an actual regex
def send_signals(self): if self.flag: invalid_ipn_received.send(sender=self) return else: valid_ipn_received.send(sender=self)
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier return_statement else_clause block expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier
Shout for the world to hear whether a txn was successful.
def _pad_string(self, str, colwidth): width = self._disp_width(str) prefix = (colwidth - 1 - width) // 2 suffix = colwidth - prefix - width return ' ' * prefix + str + ' ' * suffix
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier binary_operator parenthesized_expression binary_operator binary_operator identifier integer identifier integer expression_statement assignment identifier binary_operator binary_operator identifier identifier identifier return_statement binary_operator binary_operator binary_operator string string_start string_content string_end identifier identifier binary_operator string string_start string_content string_end identifier
Center-pads a string to the given column width using spaces.
def _update_images(self): wd_images = self.data['claims'].get('P18') if wd_images: if not isinstance(wd_images, list): wd_images = [wd_images] if 'image' not in self.data: self.data['image'] = [] for img_file in wd_images: self.data['image'].append({'file': img_file, 'kind': 'wikidata-image'})
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute subscript attribute identifier identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end if_statement identifier block if_statement not_operator call identifier argument_list identifier identifier block expression_statement assignment identifier list identifier if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end list for_statement identifier identifier block expression_statement call attribute subscript attribute identifier identifier string string_start string_content string_end identifier argument_list dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end string string_start string_content string_end
add images from Wikidata
def split_input(cls, mapper_spec): filelists = mapper_spec.params[cls.FILES_PARAM] max_values_count = mapper_spec.params.get(cls.MAX_VALUES_COUNT_PARAM, -1) max_values_size = mapper_spec.params.get(cls.MAX_VALUES_SIZE_PARAM, -1) return [cls([0] * len(files), max_values_count, max_values_size) for files in filelists]
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier unary_operator integer expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier unary_operator integer return_statement list_comprehension call identifier argument_list binary_operator list integer call identifier argument_list identifier identifier identifier for_in_clause identifier identifier
Split input into multiple shards.
def mark_module_skipped(self, module_name): try: del self.modules[module_name] except KeyError: pass self.skip_modules[module_name] = True
module function_definition identifier parameters identifier identifier block try_statement block delete_statement subscript attribute identifier identifier identifier except_clause identifier block pass_statement expression_statement assignment subscript attribute identifier identifier identifier true
Skip reloading the named module in the future
def _var(ins): output = [] output.append('%s:' % ins.quad[1]) output.append('DEFB %s' % ((int(ins.quad[2]) - 1) * '00, ' + '00')) return output
module function_definition identifier parameters identifier block expression_statement assignment identifier list expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end subscript attribute identifier identifier integer expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end parenthesized_expression binary_operator binary_operator parenthesized_expression binary_operator call identifier argument_list subscript attribute identifier identifier integer integer string string_start string_content string_end string string_start string_content string_end return_statement identifier
Defines a memory variable.
def get(self, key, recursive=False, sorted=False, quorum=False, wait=False, wait_index=None, timeout=None): url = self.make_key_url(key) params = self.build_args({ 'recursive': (bool, recursive or None), 'sorted': (bool, sorted or None), 'quorum': (bool, quorum or None), 'wait': (bool, wait or None), 'waitIndex': (int, wait_index), }) if timeout is None: while True: try: try: res = self.session.get(url, params=params) except: self.erred() except (TimedOut, ChunkedEncodingError): continue else: break else: try: res = self.session.get(url, params=params, timeout=timeout) except ChunkedEncodingError: raise TimedOut except: self.erred() return self.wrap_response(res)
module function_definition identifier parameters identifier identifier default_parameter identifier false default_parameter identifier false default_parameter identifier false default_parameter identifier false default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end tuple identifier boolean_operator identifier none pair string string_start string_content string_end tuple identifier boolean_operator identifier none pair string string_start string_content string_end tuple identifier boolean_operator identifier none pair string string_start string_content string_end tuple identifier boolean_operator identifier none pair string string_start string_content string_end tuple identifier identifier if_statement comparison_operator identifier none block while_statement true block try_statement block try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier identifier except_clause block expression_statement call attribute identifier identifier argument_list except_clause tuple identifier identifier block continue_statement else_clause block break_statement else_clause block try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier except_clause identifier block raise_statement identifier except_clause block expression_statement call attribute identifier identifier argument_list return_statement call attribute identifier identifier argument_list identifier
Requests to get a node by the given key.
def _get_privacy(self, table_name): ds_manager = DatasetManager(self.auth_client) try: dataset = ds_manager.get(table_name) return dataset.privacy.lower() except NotFoundException: return None
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement call attribute attribute identifier identifier identifier argument_list except_clause identifier block return_statement none
gets current privacy of a table
def _load_stats(self): for attempt in range(0, 3): try: with self.stats_file.open() as f: return json.load(f) except ValueError: if attempt < 2: time.sleep(attempt * 0.2) else: raise except IOError: raise IOError( "Could not read stats file {0}. Make sure you are using the " "webpack-bundle-tracker plugin" .format(self.stats_file))
module function_definition identifier parameters identifier block for_statement identifier call identifier argument_list integer integer block try_statement block with_statement with_clause with_item as_pattern call attribute attribute identifier identifier identifier argument_list as_pattern_target identifier block return_statement call attribute identifier identifier argument_list identifier except_clause identifier block if_statement comparison_operator identifier integer block expression_statement call attribute identifier identifier argument_list binary_operator identifier float else_clause block raise_statement except_clause identifier block raise_statement call identifier argument_list call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list attribute identifier identifier
Load the webpack-stats file
def reset(self): self._x = self._start_x self._y = self._start_y
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier
Reset the Path for use next time.
def size(self,value): if not self.params: self.params = dict(size=value) return self self.params['size'] = value return self
module function_definition identifier parameters identifier identifier block if_statement not_operator attribute identifier identifier block expression_statement assignment attribute identifier identifier call identifier argument_list keyword_argument identifier identifier return_statement identifier expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end identifier return_statement identifier
The number of hits to return. Defaults to 10
def aspage(self): if self.offset is None: raise ValueError('cannot return virtual frame as page.') self.parent.filehandle.seek(self.offset) return TiffPage(self.parent, index=self.index)
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block raise_statement call identifier argument_list string string_start string_content string_end expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list attribute identifier identifier return_statement call identifier argument_list attribute identifier identifier keyword_argument identifier attribute identifier identifier
Return TiffPage from file.
def convert_args(self, command, args): for wanted, arg in zip(command.argtypes(), args): wanted = wanted.type_ if(wanted == "const"): try: yield to_int(arg) except: if(arg in self.processor.constants): yield self.processor.constants[arg] else: yield arg if(wanted == "register"): yield self.register_indices[arg]
module function_definition identifier parameters identifier identifier identifier block for_statement pattern_list identifier identifier call identifier argument_list call attribute identifier identifier argument_list identifier block expression_statement assignment identifier attribute identifier identifier if_statement parenthesized_expression comparison_operator identifier string string_start string_content string_end block try_statement block expression_statement yield call identifier argument_list identifier except_clause block if_statement parenthesized_expression comparison_operator identifier attribute attribute identifier identifier identifier block expression_statement yield subscript attribute attribute identifier identifier identifier identifier else_clause block expression_statement yield identifier if_statement parenthesized_expression comparison_operator identifier string string_start string_content string_end block expression_statement yield subscript attribute identifier identifier identifier
Converts ``str -> int`` or ``register -> int``.
def generate_direct_deps(self, target: Target): yield from (self.targets[dep_name] for dep_name in sorted(target.deps))
module function_definition identifier parameters identifier typed_parameter identifier type identifier block expression_statement yield generator_expression subscript attribute identifier identifier identifier for_in_clause identifier call identifier argument_list attribute identifier identifier
Generate only direct dependencies of `target`.
def translate(self, instruction): try: trans_instrs = self.__translate(instruction) except NotImplementedError: unkn_instr = self._builder.gen_unkn() unkn_instr.address = instruction.address << 8 | (0x0 & 0xff) trans_instrs = [unkn_instr] self._log_not_supported_instruction(instruction) except Exception: self._log_translation_exception(instruction) raise return trans_instrs
module function_definition identifier parameters identifier identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier except_clause identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier binary_operator binary_operator attribute identifier identifier integer parenthesized_expression binary_operator integer integer expression_statement assignment identifier list identifier expression_statement call attribute identifier identifier argument_list identifier except_clause identifier block expression_statement call attribute identifier identifier argument_list identifier raise_statement return_statement identifier
Return IR representation of an instruction.
def save(self, filename=None): filename = filename or self._filename o = open(filename, 'w') o.write(self.write()) o.close()
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier boolean_operator identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list
Save an arff structure to a file.