code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def standalone(body): with open(_ROOT + '/html.dat', 'r') as html_template: head = html_title() html = "".join(html_template.readlines()) \ .replace("{{HEAD}}", head) \ .replace("{{BODY}}", body) return html
module function_definition identifier parameters identifier block with_statement with_clause with_item as_pattern call identifier argument_list binary_operator identifier string string_start string_content string_end string string_start string_content string_end as_pattern_target identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call attribute call attribute call attribute string string_start string_end identifier argument_list call attribute identifier identifier argument_list line_continuation identifier argument_list string string_start string_content string_end identifier line_continuation identifier argument_list string string_start string_content string_end identifier return_statement identifier
Returns complete html document given markdown html
def convert_to_broker_id(string): error_msg = 'Positive integer or -1 required, {string} given.'.format(string=string) try: value = int(string) except ValueError: raise argparse.ArgumentTypeError(error_msg) if value <= 0 and value != -1: raise argparse.ArgumentTypeError(error_msg) return value
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier try_statement block expression_statement assignment identifier call identifier argument_list identifier except_clause identifier block raise_statement call attribute identifier identifier argument_list identifier if_statement boolean_operator comparison_operator identifier integer comparison_operator identifier unary_operator integer block raise_statement call attribute identifier identifier argument_list identifier return_statement identifier
Convert string to kafka broker_id.
def clear(self): db = sqlite3.connect(self.path) c = db.cursor() c.execute("DELETE FROM dirhashcache") db.commit() db.close()
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list
Remove all cache entries.
def setSr(self, fs): self.tracePlot.setSr(fs) self.stimPlot.setSr(fs)
module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Sets the samplerate of the input operation being plotted
def update(self): self._controller.update(self._id, wake_if_asleep=False) data = self._controller.get_charging_params(self._id) if data: self.__battery_level = data['battery_level'] self.__charging_state = data['charging_state']
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier keyword_argument identifier false expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier if_statement identifier block expression_statement assignment attribute identifier identifier subscript identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier subscript identifier string string_start string_content string_end
Update the battery state.
def send_event_to_observers(self, ev, state=None): for observer in self.get_observers(ev, state): self.send_event(observer, ev, state)
module function_definition identifier parameters identifier identifier default_parameter identifier none block for_statement identifier call attribute identifier identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier identifier
Send the specified event to all observers of this RyuApp.
def get(self, mode, metric): if mode not in self._values: logging.info("Metric %s not found for mode %s", metric, mode) return [] return list(self._values[mode][metric])
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier return_statement list return_statement call identifier argument_list subscript subscript attribute identifier identifier identifier identifier
Get the history for the given metric and mode.
def _parse_disambiguate(disambiguatestatsfilename): disambig_stats = [0, 0, 0] with open(disambiguatestatsfilename, "r") as in_handle: for i, line in enumerate(in_handle): fields = line.strip().split("\t") if i == 0: assert fields == ['sample', 'unique species A pairs', 'unique species B pairs', 'ambiguous pairs'] else: disambig_stats = [x + int(y) for x, y in zip(disambig_stats, fields[1:])] return disambig_stats
module function_definition identifier parameters identifier block expression_statement assignment identifier list integer integer integer 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 for_statement pattern_list identifier identifier call identifier argument_list identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list string string_start string_content escape_sequence string_end if_statement comparison_operator identifier integer block assert_statement comparison_operator identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end else_clause block expression_statement assignment identifier list_comprehension binary_operator identifier call identifier argument_list identifier for_in_clause pattern_list identifier identifier call identifier argument_list identifier subscript identifier slice integer return_statement identifier
Parse disambiguation stats from given file.
def recipe_get(backend, recipe): recipe_root_dir = DKRecipeDisk.find_recipe_root_dir() if recipe_root_dir is None: if recipe is None: raise click.ClickException("\nPlease change to a recipe folder or provide a recipe name arguement") kitchen_root_dir = DKKitchenDisk.is_kitchen_root_dir() if not kitchen_root_dir: raise click.ClickException("\nPlease change to a recipe folder or a kitchen root dir.") recipe_name = recipe start_dir = DKKitchenDisk.find_kitchen_root_dir() else: recipe_name = DKRecipeDisk.find_recipe_name() if recipe is not None: if recipe_name != recipe: raise click.ClickException("\nThe recipe name argument '%s' is inconsistent with the current directory '%s'" % (recipe, recipe_root_dir)) start_dir = recipe_root_dir kitchen_name = Backend.get_kitchen_name_soft() click.secho("%s - Getting the latest version of Recipe '%s' in Kitchen '%s'" % (get_datetime(), recipe_name, kitchen_name), fg='green') check_and_print(DKCloudCommandRunner.get_recipe(backend.dki, kitchen_name, recipe_name, start_dir))
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier none block if_statement comparison_operator identifier none block raise_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end expression_statement assignment identifier call attribute identifier identifier argument_list if_statement not_operator identifier block raise_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end expression_statement assignment identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier none block if_statement comparison_operator identifier identifier block raise_statement call attribute identifier identifier argument_list binary_operator string string_start string_content escape_sequence string_end tuple identifier identifier expression_statement assignment identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple call identifier argument_list identifier identifier keyword_argument identifier string string_start string_content string_end expression_statement call identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier identifier identifier identifier
Get the latest files for this recipe.
def show_list(timeout_in_sec, out=sys.stdout, host=jps.env.get_master_host(), sub_port=jps.DEFAULT_SUB_PORT): class TopicNameStore(object): def __init__(self): self._topic_names = set() def callback(self, msg, topic): self._topic_names.add(topic) def get_topic_names(self): names = list(self._topic_names) names.sort() return names store = TopicNameStore() sub = jps.Subscriber('*', store.callback, host=host, sub_port=sub_port) sleep_sec = 0.01 for i in range(int(timeout_in_sec / sleep_sec)): sub.spin_once(sleep_sec) time.sleep(0.001) for name in store.get_topic_names(): out.write('{}\n'.format(name))
module function_definition identifier parameters identifier default_parameter identifier attribute identifier identifier default_parameter identifier call attribute attribute identifier identifier identifier argument_list default_parameter identifier attribute identifier identifier block class_definition identifier argument_list identifier block function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier call identifier argument_list function_definition identifier parameters identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list return_statement identifier expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier expression_statement assignment identifier float for_statement identifier call identifier argument_list call identifier argument_list binary_operator identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list float for_statement identifier call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier
get the name list of the topics, and print it
def subject_director(**kwargs): if kwargs.get('qualifier') not in ['KWD', '']: return ETD_MSSubject(scheme=kwargs.get('qualifier'), **kwargs) else: return ETD_MSSubject(content=kwargs.get('content'))
module function_definition identifier parameters dictionary_splat_pattern identifier block if_statement comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end list string string_start string_content string_end string string_start string_end block return_statement call identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list string string_start string_content string_end dictionary_splat identifier else_clause block return_statement call identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list string string_start string_content string_end
Direct how to handle a subject element.
def _get_gosrcs_upper(self, goids, max_upper, go2parentids): gosrcs_upper = set() get_nt = self.gosubdag.go2nt.get go2nt = {g:get_nt(g) for g in goids} go_nt = sorted(go2nt.items(), key=lambda t: -1*t[1].dcnt) goids_upper = set() for goid, _ in go_nt: goids_upper.add(goid) if goid in go2parentids: goids_upper |= go2parentids[goid] if len(goids_upper) < max_upper: gosrcs_upper.add(goid) else: break return gosrcs_upper
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier attribute attribute attribute identifier identifier identifier identifier expression_statement assignment identifier dictionary_comprehension pair identifier call identifier argument_list identifier for_in_clause identifier identifier expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier lambda lambda_parameters identifier binary_operator unary_operator integer attribute subscript identifier integer identifier expression_statement assignment identifier call identifier argument_list for_statement pattern_list identifier identifier identifier block expression_statement call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier identifier block expression_statement augmented_assignment identifier subscript identifier identifier if_statement comparison_operator call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list identifier else_clause block break_statement return_statement identifier
Get GO IDs for the upper portion of the GO DAG.
def Unprotect(protected_stream_id, protected_stream_key, subcon): return Switch( protected_stream_id, {'arcfourvariant': ARCFourVariantStream(protected_stream_key, subcon), 'salsa20': Salsa20Stream(protected_stream_key, subcon), 'chacha20': ChaCha20Stream(protected_stream_key, subcon), }, default=subcon )
module function_definition identifier parameters identifier identifier identifier block return_statement call identifier argument_list identifier dictionary pair string string_start string_content string_end call identifier argument_list identifier identifier pair string string_start string_content string_end call identifier argument_list identifier identifier pair string string_start string_content string_end call identifier argument_list identifier identifier keyword_argument identifier identifier
Select stream cipher based on protected_stream_id
def disable_vxlan_feature(self, nexus_host): starttime = time.time() self.send_edit_string(nexus_host, snipp.PATH_VXLAN_STATE, (snipp.BODY_VXLAN_STATE % "disabled")) self.send_edit_string(nexus_host, snipp.PATH_VNSEG_STATE, (snipp.BODY_VNSEG_STATE % "disabled")) self.capture_and_print_timeshot( starttime, "disable_vxlan", switch=nexus_host)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier parenthesized_expression binary_operator attribute identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier parenthesized_expression binary_operator attribute identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier string string_start string_content string_end keyword_argument identifier identifier
Disable VXLAN on the switch.
def _clean_data(self, str_value, file_data, obj_value): str_value = str_value or None obj_value = obj_value or None return (str_value, None, obj_value)
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier boolean_operator identifier none expression_statement assignment identifier boolean_operator identifier none return_statement tuple identifier none identifier
This overwrite is neccesary for work with multivalues
def setCurrentRegItem(self, regItem): rowIndex = self.model().indexFromItem(regItem) if not rowIndex.isValid(): logger.warn("Can't select {!r} in table".format(regItem)) self.setCurrentIndex(rowIndex)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list identifier if_statement not_operator call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier
Sets the current registry item.
def verifyCert(self, cert): tbsCert = cert.tbsCertificate sigAlg = tbsCert.signature h = hash_by_oid[sigAlg.algorithm.val] sigVal = raw(cert.signatureValue) return self.verify(raw(tbsCert), sigVal, h=h, t='pkcs')
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier subscript identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier return_statement call attribute identifier identifier argument_list call identifier argument_list identifier identifier keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end
Verifies either a Cert or an X509_Cert.
async def authenticate_with_device(atv): credentials = await atv.airplay.generate_credentials() await atv.airplay.load_credentials(credentials) try: await atv.airplay.start_authentication() pin = input('PIN Code: ') await atv.airplay.finish_authentication(pin) print('Credentials: {0}'.format(credentials)) except exceptions.DeviceAuthenticationError: print('Failed to authenticate', file=sys.stderr)
module function_definition identifier parameters identifier block expression_statement assignment identifier await call attribute attribute identifier identifier identifier argument_list expression_statement await call attribute attribute identifier identifier identifier argument_list identifier try_statement block expression_statement await call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call identifier argument_list string string_start string_content string_end expression_statement await call attribute attribute identifier identifier identifier argument_list identifier expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier except_clause attribute identifier identifier block expression_statement call identifier argument_list string string_start string_content string_end keyword_argument identifier attribute identifier identifier
Perform device authentication and print credentials.
def _register_pyflakes_check(): from flake8_isort import Flake8Isort from flake8_blind_except import check_blind_except codes = { "UnusedImport": "F401", "ImportShadowedByLoopVar": "F402", "ImportStarUsed": "F403", "LateFutureImport": "F404", "Redefined": "F801", "RedefinedInListComp": "F812", "UndefinedName": "F821", "UndefinedExport": "F822", "UndefinedLocal": "F823", "DuplicateArgument": "F831", "UnusedVariable": "F841", } for name, obj in vars(pyflakes.messages).items(): if name[0].isupper() and obj.message: obj.tpl = "{0} {1}".format(codes.get(name, "F999"), obj.message) pep8.register_check(_PyFlakesChecker, codes=['F']) parser = pep8.get_parser('', '') Flake8Isort.add_options(parser) options, args = parser.parse_args([]) pep8.register_check(Flake8Isort, codes=['I']) pep8.register_check(check_blind_except, codes=['B90'])
module function_definition identifier parameters block import_from_statement dotted_name identifier dotted_name identifier import_from_statement dotted_name identifier dotted_name identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end for_statement pattern_list identifier identifier call attribute call identifier argument_list attribute identifier identifier identifier argument_list block if_statement boolean_operator call attribute subscript identifier integer identifier argument_list attribute identifier identifier block expression_statement assignment attribute identifier identifier call attribute string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list identifier string string_start string_content string_end attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_end string string_start string_end expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list list expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier list string string_start string_content string_end
Register the pyFlakes checker into PEP8 set of checks.
def ceilpow2(n): signif,exponent = frexp(n) if (signif < 0): return 1; if (signif == 0.5): exponent -= 1; return (1) << exponent;
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier if_statement parenthesized_expression comparison_operator identifier integer block return_statement integer if_statement parenthesized_expression comparison_operator identifier float block expression_statement augmented_assignment identifier integer return_statement binary_operator parenthesized_expression integer identifier
convenience function to determine a power-of-2 upper frequency limit
def existing_path(string): if not os.path.exists(string): msg = 'path {0!r} does not exist'.format(string) raise argparse.ArgumentTypeError(msg) return string
module function_definition identifier parameters identifier block if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier raise_statement call attribute identifier identifier argument_list identifier return_statement identifier
"Convert" a string to a string that is a path to an existing file.
def rpc_stop(server_state): rpc_srv = server_state['rpc'] if rpc_srv is not None: log.info("Shutting down RPC") rpc_srv.stop_server() rpc_srv.join() log.info("RPC joined") else: log.info("RPC already joined") server_state['rpc'] = None
module function_definition identifier parameters identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end if_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end none
Stop the global RPC server thread
def csvpatch_cmd(input_csv, input=None, output=None, strict=True): patch_stream = (sys.stdin if input is None else open(input)) tocsv_stream = (sys.stdout if output is None else open(output, 'w')) fromcsv_stream = open(input_csv) try: patch_file(patch_stream, fromcsv_stream, tocsv_stream, strict=strict) except patch.InvalidPatchError as e: error.abort('reading patch, {0}'.format(e.args[0])) finally: patch_stream.close() fromcsv_stream.close() tocsv_stream.close()
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier true block expression_statement assignment identifier parenthesized_expression conditional_expression attribute identifier identifier comparison_operator identifier none call identifier argument_list identifier expression_statement assignment identifier parenthesized_expression conditional_expression attribute identifier identifier comparison_operator identifier none call identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier try_statement block expression_statement call identifier argument_list identifier identifier identifier keyword_argument identifier identifier except_clause as_pattern attribute identifier identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list subscript attribute identifier identifier integer finally_clause block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list
Apply the changes from a csvdiff patch to an existing CSV file.
def validate_experimental(context, param, value): if value is None: return config = ExperimentConfiguration(value) config.validate() return config
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator identifier none block return_statement expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list return_statement identifier
Load and validate an experimental data configuration.
def display_popup(self, title, content): assert isinstance(title, six.text_type) assert isinstance(content, six.text_type) self.popup_dialog.title = title self._popup_textarea.text = content self.client_state.display_popup = True get_app().layout.focus(self._popup_textarea)
module function_definition identifier parameters identifier identifier identifier block assert_statement call identifier argument_list identifier attribute identifier identifier assert_statement call identifier argument_list identifier attribute identifier identifier expression_statement assignment attribute attribute identifier identifier identifier identifier expression_statement assignment attribute attribute identifier identifier identifier identifier expression_statement assignment attribute attribute identifier identifier identifier true expression_statement call attribute attribute call identifier argument_list identifier identifier argument_list attribute identifier identifier
Display a pop-up dialog.
def subgraph_from(self, targets: sos_targets): if 'DAG' in env.config['SOS_DEBUG'] or 'ALL' in env.config['SOS_DEBUG']: env.log_to_file('DAG', 'create subgraph') subnodes = [] for node in self.nodes(): if node._output_targets.valid() and any( x in node._output_targets for x in targets): subnodes.append(node) ancestors = set() for node in subnodes: ancestors |= nx.ancestors(self, node) return SoS_DAG(nx.subgraph(self, subnodes + list(ancestors)))
module function_definition identifier parameters identifier typed_parameter identifier type identifier block if_statement boolean_operator comparison_operator string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end comparison_operator string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier list for_statement identifier call attribute identifier identifier argument_list block if_statement boolean_operator call attribute attribute identifier identifier identifier argument_list call identifier generator_expression comparison_operator identifier attribute identifier identifier for_in_clause identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list for_statement identifier identifier block expression_statement augmented_assignment identifier call attribute identifier identifier argument_list identifier identifier return_statement call identifier argument_list call attribute identifier identifier argument_list identifier binary_operator identifier call identifier argument_list identifier
Trim DAG to keep only nodes that produce targets
def configuration(): 'Loads configuration from the file system.' defaults = cfg = ConfigParser.SafeConfigParser() cfg.readfp(io.BytesIO(defaults)) cfg.read([ '/etc/coursera/courseraoauth2client.cfg', os.path.expanduser('~/.coursera/courseraoauth2client.cfg'), 'courseraoauth2client.cfg', ]) return cfg
module function_definition identifier parameters block expression_statement string string_start string_content string_end expression_statement assignment identifier assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list list string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end return_statement identifier
Loads configuration from the file system.
def list_extensions(request): blacklist = set(getattr(settings, 'OPENSTACK_NOVA_EXTENSIONS_BLACKLIST', [])) nova_api = _nova.novaclient(request) return tuple( extension for extension in nova_list_extensions.ListExtManager(nova_api).show_all() if extension.name not in blacklist )
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier string string_start string_content string_end list expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement call identifier generator_expression identifier for_in_clause identifier call attribute call attribute identifier identifier argument_list identifier identifier argument_list if_clause comparison_operator attribute identifier identifier identifier
List all nova extensions, except the ones in the blacklist.
def _get_evidence_bam(work_dir, data): evidence_bam = glob.glob(os.path.join(work_dir, "results", "evidence", "evidence_*.%s*.bam" % (dd.get_sample_name(data)))) if evidence_bam: return evidence_bam[0]
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end string string_start string_content string_end binary_operator string string_start string_content string_end parenthesized_expression call attribute identifier identifier argument_list identifier if_statement identifier block return_statement subscript identifier integer
Retrieve evidence BAM for the sample if it exists
def _cursor_position_changed(self): cursor = self._text_edit.textCursor() position = cursor.position() document = self._text_edit.document() char = to_text_string(document.characterAt(position - 1)) if position <= self._start_position: self.hide() elif char == ')': pos, _ = self._find_parenthesis(position - 1, forward=False) if pos == -1: self.hide()
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list binary_operator identifier integer if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list binary_operator identifier integer keyword_argument identifier false if_statement comparison_operator identifier unary_operator integer block expression_statement call attribute identifier identifier argument_list
Updates the tip based on user cursor movement.
def opened(self): if self._ddp_version_index == len(DDP_VERSIONS): self.ddpsocket._debug_log('* DDP VERSION MISMATCH') self.emit('version_mismatch', DDP_VERSIONS) return if self._retry_new_version in DDP_VERSIONS: self._ddp_version_index = [i for i, x in enumerate(DDP_VERSIONS) if x == self._retry_new_version][0] connect_msg = { "msg": "connect", "version": DDP_VERSIONS[self._ddp_version_index], "support": DDP_VERSIONS } if self._session: connect_msg["session"] = self._session self.send(connect_msg)
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier call identifier argument_list identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement if_statement comparison_operator attribute identifier identifier identifier block expression_statement assignment attribute identifier identifier subscript list_comprehension identifier for_in_clause pattern_list identifier identifier call identifier argument_list identifier if_clause comparison_operator identifier attribute identifier identifier integer expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end subscript identifier attribute identifier identifier pair string string_start string_content string_end identifier if_statement attribute identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier
Send the connect message to the server.
def flatten(nested_list: list) -> list: return list(sorted(filter(lambda y: y is not None, list(map(lambda x: (nested_list.extend(x) if isinstance(x, list) else x), nested_list)))))
module function_definition identifier parameters typed_parameter identifier type identifier type identifier block return_statement call identifier argument_list call identifier argument_list call identifier argument_list lambda lambda_parameters identifier comparison_operator identifier none call identifier argument_list call identifier argument_list lambda lambda_parameters identifier parenthesized_expression conditional_expression call attribute identifier identifier argument_list identifier call identifier argument_list identifier identifier identifier identifier
Flattens a list, ignore all the lambdas.
def hsize(bytes): sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'] if bytes == 0: return '0 Byte' i = int(math.floor(math.log(bytes) / math.log(1024))) r = round(bytes / math.pow(1024, i), 2) return str(r) + '' + sizes[i]
module function_definition identifier parameters identifier block expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end if_statement comparison_operator identifier integer block return_statement string string_start string_content string_end expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list binary_operator call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list integer expression_statement assignment identifier call identifier argument_list binary_operator identifier call attribute identifier identifier argument_list integer identifier integer return_statement binary_operator binary_operator call identifier argument_list identifier string string_start string_end subscript identifier identifier
converts a bytes to human-readable format
def star_sep_check(self, original, loc, tokens): return self.check_py("3", "keyword-only argument separator (add 'match' to front to produce universal code)", original, loc, tokens)
module function_definition identifier parameters identifier identifier identifier identifier block return_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier identifier identifier
Check for Python 3 keyword-only arguments.
def IsCloud(self, request, bios_version, services): if request.bios_version_regex and bios_version: if re.match(request.bios_version_regex, bios_version): return True if request.service_name_regex and services: if re.search(request.service_name_regex, services): return True return False
module function_definition identifier parameters identifier identifier identifier identifier block if_statement boolean_operator attribute identifier identifier identifier block if_statement call attribute identifier identifier argument_list attribute identifier identifier identifier block return_statement true if_statement boolean_operator attribute identifier identifier identifier block if_statement call attribute identifier identifier argument_list attribute identifier identifier identifier block return_statement true return_statement false
Test to see if we're on a cloud machine.
def js_on_click(self, handler): self.js_on_event(ButtonClick, handler) self.js_on_event(MenuItemClick, handler)
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier
Set up a JavaScript handler for button or menu item clicks.
def insertPhenotypeAssociationSet(self, phenotypeAssociationSet): datasetId = phenotypeAssociationSet.getParentContainer().getId() attributes = json.dumps(phenotypeAssociationSet.getAttributes()) try: models.Phenotypeassociationset.create( id=phenotypeAssociationSet.getId(), name=phenotypeAssociationSet.getLocalId(), datasetid=datasetId, dataurl=phenotypeAssociationSet._dataUrl, attributes=attributes) except Exception: raise exceptions.DuplicateNameException( phenotypeAssociationSet.getParentContainer().getId())
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier except_clause identifier block raise_statement call attribute identifier identifier argument_list call attribute call attribute identifier identifier argument_list identifier argument_list
Inserts the specified phenotype annotation set into this repository.
def make_delete_table(table: Table, delete_prefix='delete_from__') -> Table: name = delete_prefix + table.name primary_key = table.primary_key key_names = set(primary_key.column_names) columns = [column for column in table.columns if column.name in key_names] table = Table(name, columns, primary_key) return table
module function_definition identifier parameters typed_parameter identifier type identifier default_parameter identifier string string_start string_content string_end type identifier block expression_statement assignment identifier binary_operator identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier list_comprehension identifier for_in_clause identifier attribute identifier identifier if_clause comparison_operator attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier identifier return_statement identifier
Table referencing a delete from using primary key join.
def check64bit(current_system="python"): if current_system == "python": return sys.maxsize > 2147483647 elif current_system == "os": import platform pm = platform.machine() if pm != ".." and pm.endswith('64'): return True else: if 'PROCESSOR_ARCHITEW6432' in os.environ: return True try: return os.environ['PROCESSOR_ARCHITECTURE'].endswith('64') except IndexError: pass try: return '64' in platform.architecture()[0] except Exception: return False
module function_definition identifier parameters default_parameter identifier string string_start string_content string_end block if_statement comparison_operator identifier string string_start string_content string_end block return_statement comparison_operator attribute identifier identifier integer elif_clause comparison_operator identifier string string_start string_content string_end block import_statement dotted_name identifier expression_statement assignment identifier call attribute identifier identifier argument_list if_statement boolean_operator comparison_operator identifier string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end block return_statement true else_clause block if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block return_statement true try_statement block return_statement call attribute subscript attribute identifier identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end except_clause identifier block pass_statement try_statement block return_statement comparison_operator string string_start string_content string_end subscript call attribute identifier identifier argument_list integer except_clause identifier block return_statement false
checks if you are on a 64 bit platform
def key_from_ireq(ireq): if ireq.req is None and ireq.link is not None: return str(ireq.link) else: return key_from_req(ireq.req)
module function_definition identifier parameters identifier block if_statement boolean_operator comparison_operator attribute identifier identifier none comparison_operator attribute identifier identifier none block return_statement call identifier argument_list attribute identifier identifier else_clause block return_statement call identifier argument_list attribute identifier identifier
Get a standardized key for an InstallRequirement.
def _process_flux_param(self, pval, wave): if isinstance(pval, u.Quantity): self._validate_flux_unit(pval.unit) outval = units.convert_flux(self._redshift_model(wave), pval, self._internal_flux_unit).value else: outval = pval return outval
module function_definition identifier parameters identifier identifier identifier block if_statement call identifier argument_list identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier attribute call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier identifier attribute identifier identifier identifier else_clause block expression_statement assignment identifier identifier return_statement identifier
Process individual model parameter representing flux.
def dependencies(self) -> List[Dependency]: dependencies_str = DB.get_hash_value(self.key, 'dependencies') dependencies = [] for dependency in ast.literal_eval(dependencies_str): dependencies.append(Dependency(dependency)) return dependencies
module function_definition identifier parameters identifier type generic_type identifier type_parameter type identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier list for_statement identifier call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier return_statement identifier
Return the PB dependencies.
def spline_factors(u): X = np.array([(1.-u)**3 , 4-(6.*(u**2))+(3.*(u**3)) , 1.+(3.*u)+(3.*(u**2))-(3.*(u**3)) , u**3]) * (1./6) return X
module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list list binary_operator parenthesized_expression binary_operator float identifier integer binary_operator binary_operator integer parenthesized_expression binary_operator float parenthesized_expression binary_operator identifier integer parenthesized_expression binary_operator float parenthesized_expression binary_operator identifier integer binary_operator binary_operator binary_operator float parenthesized_expression binary_operator float identifier parenthesized_expression binary_operator float parenthesized_expression binary_operator identifier integer parenthesized_expression binary_operator float parenthesized_expression binary_operator identifier integer binary_operator identifier integer parenthesized_expression binary_operator float integer return_statement identifier
u is np.array
def ngram_intersection(args, parser): store = utils.get_data_store(args) corpus = utils.get_corpus(args) catalogue = utils.get_catalogue(args) store.validate(corpus, catalogue) store.intersection(catalogue, sys.stdout)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier
Outputs the results of performing an intersection query.
def _write_max_gradient(self)->None: "Writes the maximum of the gradients to Tensorboard." max_gradient = max(x.data.max() for x in self.gradients) self._add_gradient_scalar('max_gradient', scalar_value=max_gradient)
module function_definition identifier parameters identifier type none block expression_statement string string_start string_content string_end expression_statement assignment identifier call identifier generator_expression call attribute attribute identifier identifier identifier argument_list for_in_clause identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier
Writes the maximum of the gradients to Tensorboard.
def try_int(o:Any)->Any: "Try to convert `o` to int, default to `o` if not possible." if isinstance(o, (np.ndarray,Tensor)): return o if o.ndim else int(o) if isinstance(o, collections.Sized) or getattr(o,'__array_interface__',False): return o try: return int(o) except: return o
module function_definition identifier parameters typed_parameter identifier type identifier type identifier block expression_statement string string_start string_content string_end if_statement call identifier argument_list identifier tuple attribute identifier identifier identifier block return_statement conditional_expression identifier attribute identifier identifier call identifier argument_list identifier if_statement boolean_operator call identifier argument_list identifier attribute identifier identifier call identifier argument_list identifier string string_start string_content string_end false block return_statement identifier try_statement block return_statement call identifier argument_list identifier except_clause block return_statement identifier
Try to convert `o` to int, default to `o` if not possible.
def stop_sequence(self): return sorted( self.stop_times(), key=lambda x:int(x.get('stop_sequence')) )
module function_definition identifier parameters identifier block return_statement call identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier lambda lambda_parameters identifier call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end
Return the sorted StopTimes for this trip.
def apply_bbox(sf,ax): limits = sf.bbox xlim = limits[0],limits[2] ylim = limits[1],limits[3] ax.set_xlim(xlim) ax.set_ylim(ylim)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier expression_list subscript identifier integer subscript identifier integer expression_statement assignment identifier expression_list subscript identifier integer subscript identifier integer expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier
Use bbox as xlim and ylim in ax
def query(name): collection = Collection.query.filter_by(name=name).one() click.echo(collection.dbquery)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list attribute identifier identifier
Print the collection query.
def mode_in_range(a, axis=0, tol=1E-3): a_trunc = a // tol vals, counts = mode(a_trunc, axis) mask = (a_trunc == vals) return np.sum(a * mask, axis) / np.sum(mask, axis)
module function_definition identifier parameters identifier default_parameter identifier integer default_parameter identifier float block expression_statement assignment identifier binary_operator identifier identifier expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier identifier expression_statement assignment identifier parenthesized_expression comparison_operator identifier identifier return_statement binary_operator call attribute identifier identifier argument_list binary_operator identifier identifier identifier call attribute identifier identifier argument_list identifier identifier
Find the mode of values to within a certain range
def dict_from_object(obj: object): return (obj if isinstance(obj, dict) else {attr: getattr(obj, attr) for attr in dir(obj) if not attr.startswith('_')})
module function_definition identifier parameters typed_parameter identifier type identifier block return_statement parenthesized_expression conditional_expression identifier call identifier argument_list identifier identifier dictionary_comprehension pair identifier call identifier argument_list identifier identifier for_in_clause identifier call identifier argument_list identifier if_clause not_operator call attribute identifier identifier argument_list string string_start string_content string_end
Convert a object into dictionary with all of its readable attributes.
def _cache_key_select_daterange(method, self, field_id, field_title, style=None): key = update_timer(), field_id, field_title, style return key
module function_definition identifier parameters identifier identifier identifier identifier default_parameter identifier none block expression_statement assignment identifier expression_list call identifier argument_list identifier identifier identifier return_statement identifier
This function returns the key used to decide if method select_daterange has to be recomputed
def images(self): for ds_id, projectable in self.datasets.items(): if ds_id in self.wishlist: yield projectable.to_image()
module function_definition identifier parameters identifier block for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block if_statement comparison_operator identifier attribute identifier identifier block expression_statement yield call attribute identifier identifier argument_list
Generate images for all the datasets from the scene.
def onOpen(self): self.factory.add_client(self) self.factory.mease.publisher.publish( message_type=ON_OPEN, client_id=self._client_id, client_storage=self.storage)
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute attribute attribute identifier identifier identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier
Called when a client has opened a websocket connection
def predict(self, features): distances = [self._distance(x) for x in features] class_predict = [np.argmin(d) for d in distances] return self.le.inverse_transform(class_predict)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier identifier expression_statement assignment identifier list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier identifier return_statement call attribute attribute identifier identifier identifier argument_list identifier
Predict class outputs for an unlabelled feature set
def raw(self, tag, raw, metadata): raw = base64.b64encode(raw) return { 'type': 'raw', 'tag': tag, 'raw': raw, 'metadata': metadata }
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement 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 identifier pair string string_start string_content string_end identifier
Create a raw response object
def _can_circularise(self, start_hit, end_hit): if not(self._is_at_ref_start(start_hit) or self._is_at_ref_end(end_hit)): return False if self._is_at_qry_end(start_hit) \ and self._is_at_qry_start(end_hit) \ and start_hit.on_same_strand() \ and end_hit.on_same_strand(): return True if self._is_at_qry_start(start_hit) \ and self._is_at_qry_end(end_hit) \ and (not start_hit.on_same_strand()) \ and (not end_hit.on_same_strand()): return True return False
module function_definition identifier parameters identifier identifier identifier block if_statement not_operator parenthesized_expression boolean_operator call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier block return_statement false if_statement boolean_operator boolean_operator boolean_operator call attribute identifier identifier argument_list identifier line_continuation call attribute identifier identifier argument_list identifier line_continuation call attribute identifier identifier argument_list line_continuation call attribute identifier identifier argument_list block return_statement true if_statement boolean_operator boolean_operator boolean_operator call attribute identifier identifier argument_list identifier line_continuation call attribute identifier identifier argument_list identifier line_continuation parenthesized_expression not_operator call attribute identifier identifier argument_list line_continuation parenthesized_expression not_operator call attribute identifier identifier argument_list block return_statement true return_statement false
Returns true iff the two hits can be used to circularise the reference sequence of the hits
def _audio_item(self, stream_url=None, offset=0, push_buffer=True, opaque_token=None): audio_item = {'stream': {}} stream = audio_item['stream'] if not stream_url: stream['url'] = current_stream.url stream['token'] = current_stream.token stream['offsetInMilliseconds'] = current_stream.offsetInMilliseconds else: stream['url'] = stream_url stream['token'] = opaque_token or str(uuid.uuid4()) stream['offsetInMilliseconds'] = offset if push_buffer: push_stream(stream_cache, context['System']['user']['userId'], stream) return audio_item
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier integer default_parameter identifier true default_parameter identifier none block expression_statement assignment identifier dictionary pair string string_start string_content string_end dictionary expression_statement assignment identifier subscript identifier string string_start string_content string_end if_statement not_operator identifier block expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier else_clause block expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment subscript identifier string string_start string_content string_end boolean_operator identifier call identifier argument_list call attribute identifier identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end identifier if_statement identifier block expression_statement call identifier argument_list identifier subscript subscript subscript identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier return_statement identifier
Builds an AudioPlayer Directive's audioItem and updates current_stream
def _parse_bbox_list(bbox_list): if isinstance(bbox_list, BBoxCollection): return bbox_list.bbox_list, bbox_list.crs if not isinstance(bbox_list, list) or not bbox_list: raise ValueError('Expected non-empty list of BBox objects') for bbox in bbox_list: if not isinstance(bbox, BBox): raise ValueError('Elements in the list should be of type {}, got {}'.format(BBox.__name__, type(bbox))) crs = bbox_list[0].crs for bbox in bbox_list: if bbox.crs is not crs: raise ValueError('All bounding boxes should have the same CRS') return bbox_list, crs
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier identifier block return_statement expression_list attribute identifier identifier attribute identifier identifier if_statement boolean_operator not_operator call identifier argument_list identifier identifier not_operator identifier block raise_statement call identifier argument_list string string_start string_content string_end for_statement identifier identifier block if_statement not_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier call identifier argument_list identifier expression_statement assignment identifier attribute subscript identifier integer identifier for_statement identifier identifier block if_statement comparison_operator attribute identifier identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end return_statement expression_list identifier identifier
Helper method for parsing a list of bounding boxes
def apply(self, df): if self.subset: if _axis_is_rows(self.axis): df = df[self.subset] if _axis_is_cols(self.axis): df = df.loc[self.subset] result = df.agg(self.func, axis=self.axis, *self.args, **self.kwargs) result.name = self.title return result
module function_definition identifier parameters identifier identifier block if_statement attribute identifier identifier block if_statement call identifier argument_list attribute identifier identifier block expression_statement assignment identifier subscript identifier attribute identifier identifier if_statement call identifier argument_list attribute identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier attribute identifier identifier list_splat attribute identifier identifier dictionary_splat attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier return_statement identifier
Compute aggregate over DataFrame
def datetime_is_iso(date_str): try: if len(date_str) > 10: dt = isodate.parse_datetime(date_str) else: dt = isodate.parse_date(date_str) return True, [] except: return False, ['Datetime provided is not in a valid ISO 8601 format']
module function_definition identifier parameters identifier block try_statement block if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier call attribute identifier identifier argument_list identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement expression_list true list except_clause block return_statement expression_list false list string string_start string_content string_end
Attempts to parse a date formatted in ISO 8601 format
def _claim_in_progress_and_claim_channels(self, grpc_channel, channels): payments = self._call_GetListInProgress(grpc_channel) if (len(payments) > 0): self._printout("There are %i payments in 'progress' (they haven't been claimed in blockchain). We will claim them."%len(payments)) self._blockchain_claim(payments) payments = self._start_claim_channels(grpc_channel, channels) self._blockchain_claim(payments)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement parenthesized_expression comparison_operator call identifier argument_list identifier integer block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list identifier
Claim all 'pending' payments in progress and after we claim given channels
def _try_then(self): if self._cached is not None and self._callback is not None: self._callback(*self._cached[0], **self._cached[1])
module function_definition identifier parameters identifier block if_statement boolean_operator comparison_operator attribute identifier identifier none comparison_operator attribute identifier identifier none block expression_statement call attribute identifier identifier argument_list list_splat subscript attribute identifier identifier integer dictionary_splat subscript attribute identifier identifier integer
Check to see if self has been resolved yet, if so invoke then.
def InternalExchange(self, cmd, payload_in): self.logger.debug('payload: ' + str(list(payload_in))) payload = bytearray() payload[:] = payload_in for _ in range(2): self.InternalSend(cmd, payload) ret_cmd, ret_payload = self.InternalRecv() if ret_cmd == UsbHidTransport.U2FHID_ERROR: if ret_payload == UsbHidTransport.ERR_CHANNEL_BUSY: time.sleep(0.5) continue raise errors.HidError('Device error: %d' % int(ret_payload[0])) elif ret_cmd != cmd: raise errors.HidError('Command mismatch!') return ret_payload raise errors.HidError('Device Busy. Please retry')
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list expression_statement assignment subscript identifier slice identifier for_statement identifier call identifier argument_list integer block expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier attribute identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list float continue_statement raise_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list subscript identifier integer elif_clause comparison_operator identifier identifier block raise_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement identifier raise_statement call attribute identifier identifier argument_list string string_start string_content string_end
Sends and receives a message from the device.
def run_init_tables(*args): print('--') create_table(TabPost) create_table(TabTag) create_table(TabMember) create_table(TabWiki) create_table(TabLink) create_table(TabEntity) create_table(TabPostHist) create_table(TabWikiHist) create_table(TabCollect) create_table(TabPost2Tag) create_table(TabRel) create_table(TabEvaluation) create_table(TabUsage) create_table(TabReply) create_table(TabUser2Reply) create_table(TabRating) create_table(TabEntity2User) create_table(TabLog)
module function_definition identifier parameters list_splat_pattern identifier block expression_statement call identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list identifier expression_statement call identifier argument_list identifier expression_statement call identifier argument_list identifier expression_statement call identifier argument_list identifier expression_statement call identifier argument_list identifier expression_statement call identifier argument_list identifier expression_statement call identifier argument_list identifier expression_statement call identifier argument_list identifier expression_statement call identifier argument_list identifier expression_statement call identifier argument_list identifier expression_statement call identifier argument_list identifier expression_statement call identifier argument_list identifier expression_statement call identifier argument_list identifier expression_statement call identifier argument_list identifier expression_statement call identifier argument_list identifier expression_statement call identifier argument_list identifier expression_statement call identifier argument_list identifier expression_statement call identifier argument_list identifier
Run to init tables.
def stats(self): return self._client.get('{}/stats'.format(Instance.api_endpoint), model=self)
module function_definition identifier parameters identifier block return_statement call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier keyword_argument identifier identifier
Returns the JSON stats for this Instance
def info_community(self,teamid): headers = {"Content-type": "application/x-www-form-urlencoded","Accept": "text/plain",'Referer': 'http://'+self.domain+'/standings.phtml',"User-Agent": user_agent} req = self.session.get('http://'+self.domain+'/teamInfo.phtml?tid='+teamid,headers=headers).content soup = BeautifulSoup(req) info = [] for i in soup.find('table',cellpadding=2).find_all('tr')[1:]: info.append('%s\t%s\t%s\t%s\t%s'%(i.find('td').text,i.find('a')['href'].split('pid=')[1],i.a.text,i.find_all('td')[2].text,i.find_all('td')[3].text)) return info
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end binary_operator binary_operator string string_start string_content string_end attribute identifier identifier string string_start string_content string_end pair string string_start string_content string_end identifier expression_statement assignment identifier attribute call attribute attribute identifier identifier identifier argument_list binary_operator binary_operator binary_operator string string_start string_content string_end attribute identifier identifier string string_start string_content string_end identifier keyword_argument identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier list for_statement identifier subscript call attribute call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier integer identifier argument_list string string_start string_content string_end slice integer block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content escape_sequence escape_sequence escape_sequence escape_sequence string_end tuple attribute call attribute identifier identifier argument_list string string_start string_content string_end identifier subscript call attribute subscript call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier argument_list string string_start string_content string_end integer attribute attribute identifier identifier identifier attribute subscript call attribute identifier identifier argument_list string string_start string_content string_end integer identifier attribute subscript call attribute identifier identifier argument_list string string_start string_content string_end integer identifier return_statement identifier
Get comunity info using a ID
def stats_table(self, data): headers = OrderedDict() headers['combopairs'] = { 'title': 'Combined pairs', 'description': 'Num read pairs combined', 'shared_key': 'read_count', 'hidden': True, 'scale': False } headers['perccombo'] = { 'title': '% Combined', 'description': '% read pairs combined', 'max': 100, 'min': 0, 'suffix': '%', 'scale': 'PiYG' } self.general_stats_addcols(data, headers)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end true pair string string_start string_content string_end false expression_statement assignment subscript identifier string string_start string_content string_end dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end integer pair string string_start string_content string_end integer pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier identifier
Add percent combined to general stats table
async def add(gc: GroupControl, slaves): click.echo("Adding to existing group: %s" % slaves) click.echo(await gc.add(slaves))
module function_definition identifier parameters typed_parameter identifier type identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list await call attribute identifier identifier argument_list identifier
Add speakers to group.
def _build_backend(): ep = os.environ['PEP517_BUILD_BACKEND'] mod_path, _, obj_path = ep.partition(':') try: obj = import_module(mod_path) except ImportError: raise BackendUnavailable if obj_path: for path_part in obj_path.split('.'): obj = getattr(obj, path_part) return obj
module function_definition identifier parameters block expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment pattern_list identifier identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end try_statement block expression_statement assignment identifier call identifier argument_list identifier except_clause identifier block raise_statement identifier if_statement identifier block for_statement identifier call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list identifier identifier return_statement identifier
Find and load the build backend
def _copy(src_file, dest_path): tf.io.gfile.makedirs(os.path.dirname(dest_path)) with tf.io.gfile.GFile(dest_path, 'wb') as dest_file: while True: data = src_file.read(io.DEFAULT_BUFFER_SIZE) if not data: break dest_file.write(data)
module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier with_statement with_clause with_item as_pattern call attribute attribute attribute identifier identifier identifier identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block while_statement true block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier if_statement not_operator identifier block break_statement expression_statement call attribute identifier identifier argument_list identifier
Copy data read from src file obj to new file in dest_path.
def fields_from_dict(d): class_container = FieldsContainer.class_container fields = [field_cls.from_dict(field_dict) for field_cls, container in class_container.iteritems() for field_dict in d.get(container, [])] return fields
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier list_comprehension call attribute identifier identifier argument_list identifier for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list for_in_clause identifier call attribute identifier identifier argument_list identifier list return_statement identifier
Load the fields from the dict, return a list with all the fields.
def default(self, obj): if hasattr(obj, '__dict__'): return obj.__dict__.copy() elif HAS_NUMPY and isinstance(obj, np.ndarray): return obj.copy().tolist() else: raise TypeError(("Object of type {:s} with value of {:s} is not " "JSON serializable").format(type(obj), repr(obj)))
module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list identifier string string_start string_content string_end block return_statement call attribute attribute identifier identifier identifier argument_list elif_clause boolean_operator identifier call identifier argument_list identifier attribute identifier identifier block return_statement call attribute call attribute identifier identifier argument_list identifier argument_list else_clause block raise_statement call identifier argument_list call attribute parenthesized_expression concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list call identifier argument_list identifier call identifier argument_list identifier
Fired when an unserializable object is hit.
def _resolve(self): self.__is_resolved = True if self.is_complex: type = self.nested if self.nested else self type.__reference = self.module.lookup(type.name)
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier true if_statement attribute identifier identifier block expression_statement assignment identifier conditional_expression attribute identifier identifier attribute identifier identifier identifier expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier
resolve the type symbol from name by doing a lookup
def raise_right_error(response): if response.status_code == 200: return if response.status_code == 500: raise ServerError('Clef servers are down.') if response.status_code == 403: message = response.json().get('error') error_class = MESSAGE_TO_ERROR_MAP[message] if error_class == InvalidOAuthTokenError: message = 'Something went wrong at Clef. Unable to retrieve user information with this token.' raise error_class(message) if response.status_code == 400: message = response.json().get('error') error_class = MESSAGE_TO_ERROR_MAP[message] if error_class: raise error_class(message) else: raise InvalidLogoutTokenError(message) if response.status_code == 404: raise NotFoundError('Unable to retrieve the page. Are you sure the Clef API endpoint is configured right?') raise APIError
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier integer block return_statement if_statement comparison_operator attribute identifier identifier integer block raise_statement call identifier argument_list string string_start string_content string_end if_statement comparison_operator attribute identifier identifier integer block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list string string_start string_content string_end expression_statement assignment identifier subscript identifier identifier if_statement comparison_operator identifier identifier block expression_statement assignment identifier string string_start string_content string_end raise_statement call identifier argument_list identifier if_statement comparison_operator attribute identifier identifier integer block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list string string_start string_content string_end expression_statement assignment identifier subscript identifier identifier if_statement identifier block raise_statement call identifier argument_list identifier else_clause block raise_statement call identifier argument_list identifier if_statement comparison_operator attribute identifier identifier integer block raise_statement call identifier argument_list string string_start string_content string_end raise_statement identifier
Raise appropriate error when bad response received.
def deliver_slice(schedule): if schedule.email_format == SliceEmailReportFormat.data: email = _get_slice_data(schedule) elif schedule.email_format == SliceEmailReportFormat.visualization: email = _get_slice_visualization(schedule) else: raise RuntimeError('Unknown email report format') subject = __( '%(prefix)s %(title)s', prefix=config.get('EMAIL_REPORTS_SUBJECT_PREFIX'), title=schedule.slice.slice_name, ) _deliver_email(schedule, subject, email)
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment identifier call identifier argument_list identifier elif_clause comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment identifier call identifier argument_list identifier else_clause block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list string string_start string_content string_end keyword_argument identifier call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier attribute attribute identifier identifier identifier expression_statement call identifier argument_list identifier identifier identifier
Given a schedule, delivery the slice as an email report
def _strip_invisible(s): "Remove invisible ANSI color codes." if isinstance(s, _text_type): return re.sub(_invisible_codes, "", s) else: return re.sub(_invisible_codes_bytes, "", s)
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end if_statement call identifier argument_list identifier identifier block return_statement call attribute identifier identifier argument_list identifier string string_start string_end identifier else_clause block return_statement call attribute identifier identifier argument_list identifier string string_start string_end identifier
Remove invisible ANSI color codes.
def split_kwargs_by_func(kwargs, func): "Split `kwargs` between those expected by `func` and the others." args = func_args(func) func_kwargs = {a:kwargs.pop(a) for a in args if a in kwargs} return func_kwargs, kwargs
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 identifier expression_statement assignment identifier dictionary_comprehension pair identifier call attribute identifier identifier argument_list identifier for_in_clause identifier identifier if_clause comparison_operator identifier identifier return_statement expression_list identifier identifier
Split `kwargs` between those expected by `func` and the others.
def bin_to_int(string): if isinstance(string, str): return struct.unpack("b", string)[0] else: return struct.unpack("b", bytes([string]))[0]
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier identifier block return_statement subscript call attribute identifier identifier argument_list string string_start string_content string_end identifier integer else_clause block return_statement subscript call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list list identifier integer
Convert a one element byte string to signed int for python 2 support.
def canonical_coords(gate: Gate) -> Sequence[float]: circ = canonical_decomposition(gate) gate = circ.elements[6] params = [gate.params[key] for key in ('tx', 'ty', 'tz')] return params
module function_definition identifier parameters typed_parameter identifier type identifier type generic_type identifier type_parameter type identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier subscript attribute identifier identifier integer expression_statement assignment identifier list_comprehension subscript attribute identifier identifier 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 return_statement identifier
Returns the canonical coordinates of a 2-qubit gate
def _get_header(self, header): if header is None: html = self.header() else: html = header return html
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list else_clause block expression_statement assignment identifier identifier return_statement identifier
Gets the html header
def DeleteOldCronJobRuns(self, cutoff_timestamp, cursor=None): query = "DELETE FROM cron_job_runs WHERE write_time < FROM_UNIXTIME(%s)" cursor.execute(query, [mysql_utils.RDFDatetimeToTimestamp(cutoff_timestamp)])
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier list call attribute identifier identifier argument_list identifier
Deletes cron job runs that are older then the given timestamp.
def html(self): if self.description: tooltip = 'tooltip="{}"'.format(self.description) else: tooltip = '' return entry_html( title=self.title, thumbnail=self.thumbnail, link=self.html_link, tooltip=tooltip)
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier else_clause block expression_statement assignment identifier string string_start string_end return_statement call identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier
Return html for a the entry
def range(self): match = self._match(in_comment( 'n[ \t]+in[ \t]*\\[([0-9]+)\\.\\.([0-9]+)\\),[ \t]+' 'step[ \t]+([0-9]+)' )) return range( int(match.group(1)), int(match.group(2)), int(match.group(3)) )
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list concatenated_string string string_start string_content escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence escape_sequence string_end string string_start string_content escape_sequence string_end return_statement call identifier argument_list call identifier argument_list call attribute identifier identifier argument_list integer call identifier argument_list call attribute identifier identifier argument_list integer call identifier argument_list call attribute identifier identifier argument_list integer
Returns the range for N
def _apply_incoming_manipulators(self, son, collection): for manipulator in self.__incoming_manipulators: son = manipulator.transform_incoming(son, collection) return son
module function_definition identifier parameters identifier identifier identifier block for_statement identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier return_statement identifier
Apply incoming manipulators to `son`.
def remove_sign_link(self, ca_name, signee_name): ca_record = self.get_record(ca_name) signee_record = self.get_record(signee_name) signees = ca_record['signees'] or {} signees = Counter(signees) if signee_name in signees: signees[signee_name] = 0 ca_record['signees'] = signees signee_record['parent_ca'] = '' self.save()
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier boolean_operator subscript identifier string string_start string_content string_end dictionary expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier identifier block expression_statement assignment subscript identifier identifier integer expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_end expression_statement call attribute identifier identifier argument_list
Removes signee_name to the signee list for ca_name
def add_field(self, name, script, lang=None, params=None, ignore_failure=False): data = {} if lang: data["lang"] = lang if script: data['script'] = script else: raise ScriptFieldsError("Script is required for script_fields definition") if params: if isinstance(params, dict): if len(params): data['params'] = params else: raise ScriptFieldsError("Parameters should be a valid dictionary") if ignore_failure: data['ignore_failure'] = ignore_failure self.fields[name] = data
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier false block expression_statement assignment identifier dictionary if_statement identifier block expression_statement assignment subscript identifier string string_start string_content string_end identifier if_statement identifier block expression_statement assignment subscript identifier string string_start string_content string_end identifier else_clause block raise_statement call identifier argument_list string string_start string_content string_end if_statement identifier block if_statement call identifier argument_list identifier identifier block if_statement call identifier argument_list identifier block expression_statement assignment subscript identifier string string_start string_content string_end identifier else_clause block raise_statement call identifier argument_list string string_start string_content string_end if_statement identifier block expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment subscript attribute identifier identifier identifier identifier
Add a field to script_fields
def up(self): if self.frame: self.frame = self.frame.f_back return self.frame is None
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block expression_statement assignment attribute identifier identifier attribute attribute identifier identifier identifier return_statement comparison_operator attribute identifier identifier none
Go up in stack and return True if top frame
def _posterior(self, x): yedge = self._nuis_pdf.marginalization_bins() yc = 0.5 * (yedge[1:] + yedge[:-1]) yw = yedge[1:] - yedge[:-1] like_array = self.like(x[:, np.newaxis], yc[np.newaxis, :]) * yw like_array /= like_array.sum() self._post = like_array.sum(1) self._post_interp = castro.Interpolator(x, self._post) return self._post
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier binary_operator float parenthesized_expression binary_operator subscript identifier slice integer subscript identifier slice unary_operator integer expression_statement assignment identifier binary_operator subscript identifier slice integer subscript identifier slice unary_operator integer expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list subscript identifier slice attribute identifier identifier subscript identifier attribute identifier identifier slice identifier expression_statement augmented_assignment identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list integer expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier attribute identifier identifier return_statement attribute identifier identifier
Internal function to calculate and cache the posterior
def current_state_str(self): if self.sample_ok: msg = '' temperature = self._get_value_opc_attr('temperature') if temperature is not None: msg += 'Temp: %s ºC, ' % temperature humidity = self._get_value_opc_attr('humidity') if humidity is not None: msg += 'Humid: %s %%, ' % humidity pressure = self._get_value_opc_attr('pressure') if pressure is not None: msg += 'Press: %s mb, ' % pressure light_level = self._get_value_opc_attr('light_level') if light_level is not None: msg += 'Light: %s lux, ' % light_level return msg[:-2] else: return "Bad sample"
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block expression_statement assignment identifier string string_start string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier none block expression_statement augmented_assignment identifier binary_operator string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier none block expression_statement augmented_assignment identifier binary_operator string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier none block expression_statement augmented_assignment identifier binary_operator string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier none block expression_statement augmented_assignment identifier binary_operator string string_start string_content string_end identifier return_statement subscript identifier slice unary_operator integer else_clause block return_statement string string_start string_content string_end
Return string representation of the current state of the sensor.
def print_results(results, outfile): for stanza_words, scheme in results: outfile.write(str(' ').join(stanza_words) + str('\n')) outfile.write(str(' ').join(map(str, scheme)) + str('\n\n')) outfile.close() logging.info("Wrote result")
module function_definition identifier parameters identifier identifier block for_statement pattern_list identifier identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator call attribute call identifier argument_list string string_start string_content string_end identifier argument_list identifier call identifier argument_list string string_start string_content escape_sequence string_end expression_statement call attribute identifier identifier argument_list binary_operator call attribute call identifier argument_list string string_start string_content string_end identifier argument_list call identifier argument_list identifier identifier call identifier argument_list string string_start string_content escape_sequence escape_sequence string_end expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end
Write results to outfile
def create_app(): app = Flask(__name__) app.config_from_envvar = app.config.from_envvar app.config_from_object = app.config.from_object configure_app(app) init_core(app) register_blueprints(app) return app
module function_definition identifier parameters block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment attribute identifier identifier attribute attribute identifier identifier identifier expression_statement assignment attribute identifier identifier attribute attribute identifier identifier identifier expression_statement call identifier argument_list identifier expression_statement call identifier argument_list identifier expression_statement call identifier argument_list identifier return_statement identifier
Flask application factory function.
def _encode(self): obj = {k: v for k, v in self.__dict__.items() if not k.startswith('_') and type(v) in SAFE_TYPES} obj.update({k: v._encode() for k, v in self.__dict__.items() if isinstance(v, Ent)}) return obj
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary_comprehension pair identifier identifier for_in_clause pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list if_clause boolean_operator not_operator call attribute identifier identifier argument_list string string_start string_content string_end comparison_operator call identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list dictionary_comprehension pair identifier call attribute identifier identifier argument_list for_in_clause pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list if_clause call identifier argument_list identifier identifier return_statement identifier
Generate a recursive JSON representation of the ent.
def _is_version_range(req): assert len(req.specifier) > 0 specs = list(req.specifier) if len(specs) == 1: return specs[0].operator != '==' else: return True
module function_definition identifier parameters identifier block assert_statement comparison_operator call identifier argument_list attribute identifier identifier integer expression_statement assignment identifier call identifier argument_list attribute identifier identifier if_statement comparison_operator call identifier argument_list identifier integer block return_statement comparison_operator attribute subscript identifier integer identifier string string_start string_content string_end else_clause block return_statement true
Returns true if requirements specify a version range.
def blockcode(self, text, lang): if lang and self._config.get('highlight_syntax', 'True'): try: lexer = pygments.lexers.get_lexer_by_name(lang, stripall=True) except pygments.lexers.ClassNotFound: lexer = None if lexer: formatter = pygments.formatters.HtmlFormatter() return pygments.highlight(text, lexer, formatter) return '\n<div class="highlight"><pre>{}</pre></div>\n'.format( flask.escape(text.strip()))
module function_definition identifier parameters identifier identifier identifier block if_statement boolean_operator identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end block try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier true except_clause attribute attribute identifier identifier identifier block expression_statement assignment identifier none if_statement identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list return_statement call attribute identifier identifier argument_list identifier identifier identifier return_statement call attribute string string_start string_content escape_sequence escape_sequence string_end identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list
Pass a code fence through pygments
def combining_successors(state, last_action=()): ((corner, edge), (L, U, F, D, R, B)) = state U_turns = [Formula("U"), Formula("U'"), Formula("U2")] if len(last_action) != 1 else [] R_turns = [Formula("R U R'"), Formula("R U' R'"), Formula("R U2 R'")] if "R" not in last_action else [] F_turns = [Formula("F' U F"), Formula("F' U' F"), Formula("F' U2 F")] if "F" not in last_action else [] for act in (U_turns + R_turns + F_turns): new = (corner, edge) for q in act: new = F2LPairSolver._rotate(new, q) yield act, (new, (L, U, F, D, R, B))
module function_definition identifier parameters identifier default_parameter identifier tuple block expression_statement assignment tuple_pattern tuple_pattern identifier identifier tuple_pattern identifier identifier identifier identifier identifier identifier identifier expression_statement assignment identifier conditional_expression list call identifier argument_list string string_start string_content string_end call identifier argument_list string string_start string_content string_end call identifier argument_list string string_start string_content string_end comparison_operator call identifier argument_list identifier integer list expression_statement assignment identifier conditional_expression list call identifier argument_list string string_start string_content string_end call identifier argument_list string string_start string_content string_end call identifier argument_list string string_start string_content string_end comparison_operator string string_start string_content string_end identifier list expression_statement assignment identifier conditional_expression list call identifier argument_list string string_start string_content string_end call identifier argument_list string string_start string_content string_end call identifier argument_list string string_start string_content string_end comparison_operator string string_start string_content string_end identifier list for_statement identifier parenthesized_expression binary_operator binary_operator identifier identifier identifier block expression_statement assignment identifier tuple identifier identifier for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement yield expression_list identifier tuple identifier tuple identifier identifier identifier identifier identifier identifier
Successors function for finding path of combining F2L pair.
def _get_bucket_name(**values): app = current_app values.pop('_external', False) values.pop('_anchor', None) values.pop('_method', None) url_style = get_setting('FLASKS3_URL_STYLE', app) if url_style == 'host': url_format = '{bucket_name}.{bucket_domain}' elif url_style == 'path': url_format = '{bucket_domain}/{bucket_name}' else: raise ValueError('Invalid S3 URL style: "{}"'.format(url_style)) if get_setting('FLASKS3_CDN_DOMAIN', app): bucket_path = '{}'.format(get_setting('FLASKS3_CDN_DOMAIN', app)) else: bucket_path = url_format.format( bucket_name=get_setting('FLASKS3_BUCKET_NAME', app), bucket_domain=get_setting('FLASKS3_BUCKET_DOMAIN', app), ) bucket_path += _get_statics_prefix(app).rstrip('/') return bucket_path, values
module function_definition identifier parameters dictionary_splat_pattern identifier block expression_statement assignment identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end false expression_statement call attribute identifier identifier argument_list string string_start string_content string_end none expression_statement call attribute identifier identifier argument_list string string_start string_content string_end none expression_statement assignment identifier call identifier argument_list string string_start string_content string_end identifier if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier string string_start string_content string_end elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier string string_start string_content string_end else_clause block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier if_statement call identifier argument_list string string_start string_content string_end identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list call identifier argument_list string string_start string_content string_end identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier call identifier argument_list string string_start string_content string_end identifier keyword_argument identifier call identifier argument_list string string_start string_content string_end identifier expression_statement augmented_assignment identifier call attribute call identifier argument_list identifier identifier argument_list string string_start string_content string_end return_statement expression_list identifier identifier
Generates the bucket name for url_for.
def write_into(self, block, level=0): for line, l in self._lines: block.write_line(line, level + l) for name, obj in _compat.iteritems(self._deps): block.add_dependency(name, obj)
module function_definition identifier parameters identifier identifier default_parameter identifier integer block for_statement pattern_list identifier identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier binary_operator identifier identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier
Append this block to another one, passing all dependencies
def previous_weekday(day=None, as_datetime=False): if day is None: day = datetime.datetime.now() else: day = datetime.datetime.strptime(day, '%Y-%m-%d') day -= datetime.timedelta(days=1) while day.weekday() > 4: day -= datetime.timedelta(days=1) if as_datetime: return day return day.strftime("%Y-%m-%d")
module function_definition identifier parameters default_parameter identifier none default_parameter identifier false block if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list else_clause block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end expression_statement augmented_assignment identifier call attribute identifier identifier argument_list keyword_argument identifier integer while_statement comparison_operator call attribute identifier identifier argument_list integer block expression_statement augmented_assignment identifier call attribute identifier identifier argument_list keyword_argument identifier integer if_statement identifier block return_statement identifier return_statement call attribute identifier identifier argument_list string string_start string_content string_end
get the most recent business day
def parents(self, resources): if self.docname == 'index': return [] parents = [] parent = resources.get(self.parent) while parent is not None: parents.append(parent) parent = resources.get(parent.parent) return parents
module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block return_statement list expression_statement assignment identifier list expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier while_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier return_statement identifier
Split the path in name and get parents