code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def update_warning(self): widget = self._button_warning if not self.is_valid(): tip = _('Array dimensions not valid') widget.setIcon(ima.icon('MessageBoxWarning')) widget.setToolTip(tip) QToolTip.showText(self._widget.mapToGlobal(QPoint(0, 5)), tip) else: self._button_warning.setToolTip('')
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier if_statement not_operator call attribute identifier identifier argument_list block expression_statement assignment identifier call identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list call identifier argument_list integer integer identifier else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_end
Updates the icon and tip based on the validity of the array content.
def formfield_for_manytomany(self, db_field, request, **kwargs): if db_field.name == 'authors': kwargs['queryset'] = Author.objects.filter( Q(is_staff=True) | Q(entries__isnull=False) ).distinct() return super(EntryAdmin, self).formfield_for_manytomany( db_field, request, **kwargs)
module function_definition identifier parameters identifier identifier identifier dictionary_splat_pattern identifier block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment subscript identifier string string_start string_content string_end call attribute call attribute attribute identifier identifier identifier argument_list binary_operator call identifier argument_list keyword_argument identifier true call identifier argument_list keyword_argument identifier false identifier argument_list return_statement call attribute call identifier argument_list identifier identifier identifier argument_list identifier identifier dictionary_splat identifier
Filter the disposable authors.
def check_keypoint(kp, rows, cols): for name, value, size in zip(['x', 'y'], kp[:2], [cols, rows]): if not 0 <= value < size: raise ValueError( 'Expected {name} for keypoint {kp} ' 'to be in the range [0.0, {size}], got {value}.'.format( kp=kp, name=name, value=value, size=size ) )
module function_definition identifier parameters identifier identifier identifier block for_statement pattern_list identifier identifier identifier call identifier argument_list list string string_start string_content string_end string string_start string_content string_end subscript identifier slice integer list identifier identifier block if_statement not_operator comparison_operator integer identifier identifier block raise_statement call identifier argument_list call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
Check if keypoint coordinates are in range [0, 1)
def column_to_intermediary(col, type_formatter=format_type): return Column( name=col.name, type=type_formatter(col.type), is_key=col.primary_key, )
module function_definition identifier parameters identifier default_parameter identifier identifier block return_statement call identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier call identifier argument_list attribute identifier identifier keyword_argument identifier attribute identifier identifier
Transform an SQLAlchemy Column object to it's intermediary representation.
def generate_pages(self): for page in self.pages: self.generate_page(page.slug, template='page.html.jinja', page=page)
module function_definition identifier parameters identifier block for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier identifier
Generate HTML out of the pages added to the blog.
def add_state(self, string): parsed_string = string.split() if len(parsed_string) > 0: state, rules = parsed_string[0], parsed_string[1:] if len(rules) != len(self.alphabet): raise SyntaxError('Wrong count of rules ({cur}/{exp}): {string}' .format(cur=len(rules), exp=len(self.alphabet), string=string)) if state in self.states or state == self.TERM_STATE: raise SyntaxError('Double definition of state: ' + state) else: self.states[state] = [] for rule in rules: try: self._add_rule(state, rule) except SyntaxError as err: self.states.pop(state) raise err
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment pattern_list identifier identifier expression_list subscript identifier integer subscript identifier slice integer if_statement comparison_operator call identifier argument_list identifier call identifier argument_list attribute identifier identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier call identifier argument_list identifier keyword_argument identifier call identifier argument_list attribute identifier identifier keyword_argument identifier identifier if_statement boolean_operator comparison_operator identifier attribute identifier identifier comparison_operator identifier attribute identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier else_clause block expression_statement assignment subscript attribute identifier identifier identifier list for_statement identifier identifier block try_statement block expression_statement call attribute identifier identifier argument_list identifier identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier raise_statement identifier
Add state and rules to machine.
def _create_type(self, env, item): if item.name in env: existing_dt = env[item.name] raise InvalidSpec( 'Symbol %s already defined (%s:%d).' % (quote(item.name), existing_dt._ast_node.path, existing_dt._ast_node.lineno), item.lineno, item.path) namespace = self.api.ensure_namespace(env.namespace_name) if isinstance(item, AstStructDef): try: api_type = Struct(name=item.name, namespace=namespace, ast_node=item) except ParameterError as e: raise InvalidSpec( 'Bad declaration of %s: %s' % (quote(item.name), e.args[0]), item.lineno, item.path) elif isinstance(item, AstUnionDef): api_type = Union( name=item.name, namespace=namespace, ast_node=item, closed=item.closed) else: raise AssertionError('Unknown type definition %r' % type(item)) env[item.name] = api_type return api_type
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator attribute identifier identifier identifier block expression_statement assignment identifier subscript identifier attribute identifier identifier raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple call identifier argument_list attribute identifier identifier attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier if_statement call identifier argument_list identifier identifier block try_statement block expression_statement assignment identifier call identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier except_clause as_pattern identifier as_pattern_target identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple call identifier argument_list attribute identifier identifier subscript attribute identifier identifier integer attribute identifier identifier attribute identifier identifier elif_clause call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier else_clause block raise_statement call identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list identifier expression_statement assignment subscript identifier attribute identifier identifier identifier return_statement identifier
Create a forward reference for a union or struct.
def _get_registry(self, registry_path_or_url): if os.path.isfile(registry_path_or_url): with open(registry_path_or_url, 'r') as f: reader = compat.csv_dict_reader(f.readlines()) else: res = requests.get(registry_path_or_url) res.raise_for_status() reader = compat.csv_dict_reader(StringIO(res.text)) return dict([(o['id'], o) for o in reader])
module function_definition identifier parameters identifier identifier block if_statement call attribute attribute identifier identifier identifier argument_list identifier block with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list attribute identifier identifier return_statement call identifier argument_list list_comprehension tuple subscript identifier string string_start string_content string_end identifier for_in_clause identifier identifier
Return a dict with objects mapped by their id from a CSV endpoint
def OnClearGlobals(self, event): msg = _("Deleting globals and reloading modules cannot be undone." " Proceed?") short_msg = _("Really delete globals and modules?") choice = self.main_window.interfaces.get_warning_choice(msg, short_msg) if choice: self.main_window.grid.actions.clear_globals_reload_modules() statustext = _("Globals cleared and base modules reloaded.") post_command_event(self.main_window, self.main_window.StatusBarMsg, text=statustext)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list identifier identifier if_statement identifier block expression_statement call attribute attribute attribute attribute identifier identifier identifier identifier identifier argument_list expression_statement assignment identifier call identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list attribute identifier identifier attribute attribute identifier identifier identifier keyword_argument identifier identifier
Clear globals event handler
def do_reload(self, args): if args.module is not None: if args.module not in self.frmwk.modules: self.print_error('Invalid Module Selected.') return module = self.frmwk.modules[args.module] elif self.frmwk.current_module: module = self.frmwk.current_module else: self.print_error('Must \'use\' module first') return self.reload_module(module)
module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier none block if_statement comparison_operator attribute identifier identifier attribute attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement expression_statement assignment identifier subscript attribute attribute identifier identifier identifier attribute identifier identifier elif_clause attribute attribute identifier identifier identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence escape_sequence string_end return_statement expression_statement call attribute identifier identifier argument_list identifier
Reload a module in to the framework
def interactor(self, geneList=None, org=None): geneList = geneList or [] organisms = organisms or [] querydata = self.interactions(geneList, org) returnData = {} for i in querydata: if not returnData.get(i["symB"]["name"]): returnData[i["symB"]["name"]] = {"interactions": []} returnData[i["symB"]["name"]]["interactions"].append(i) return returnData
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier boolean_operator identifier list expression_statement assignment identifier boolean_operator identifier list expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier dictionary for_statement identifier identifier block if_statement not_operator call attribute identifier identifier argument_list subscript subscript identifier string string_start string_content string_end string string_start string_content string_end block expression_statement assignment subscript identifier subscript subscript identifier string string_start string_content string_end string string_start string_content string_end dictionary pair string string_start string_content string_end list expression_statement call attribute subscript subscript identifier 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 argument_list identifier return_statement identifier
Supposing geneList returns an unique item.
def add_arrow(self, x1, y1, x2, y2, **kws): self.panel.add_arrow(x1, y1, x2, y2, **kws)
module function_definition identifier parameters identifier identifier identifier identifier identifier dictionary_splat_pattern identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier identifier identifier dictionary_splat identifier
add arrow to plot
def pull_stream(image): return (json.loads(s) for s in _get_docker().pull(image, stream=True))
module function_definition identifier parameters identifier block return_statement generator_expression call attribute identifier identifier argument_list identifier for_in_clause identifier call attribute call identifier argument_list identifier argument_list identifier keyword_argument identifier true
Return generator of pull status objects
def _bse_cli_list_ref_formats(args): all_refformats = api.get_reference_formats() if args.no_description: liststr = all_refformats.keys() else: liststr = format_columns(all_refformats.items()) return '\n'.join(liststr)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list else_clause block expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list return_statement call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier
Handles the list-ref-formats subcommand
def handle_log_data_missing(self): if len(self.download_set) == 0: return highest = max(self.download_set) diff = set(range(highest)).difference(self.download_set) if len(diff) == 0: self.master.mav.log_request_data_send(self.target_system, self.target_component, self.download_lognum, (1 + highest) * 90, 0xffffffff) self.retries += 1 else: num_requests = 0 while num_requests < 20: start = min(diff) diff.remove(start) end = start while end + 1 in diff: end += 1 diff.remove(end) self.master.mav.log_request_data_send(self.target_system, self.target_component, self.download_lognum, start * 90, (end + 1 - start) * 90) num_requests += 1 self.retries += 1 if len(diff) == 0: break
module function_definition identifier parameters identifier block if_statement comparison_operator call identifier argument_list attribute identifier identifier integer block return_statement expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute call identifier argument_list call identifier argument_list identifier identifier argument_list attribute identifier identifier if_statement comparison_operator call identifier argument_list identifier integer block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier binary_operator parenthesized_expression binary_operator integer identifier integer integer expression_statement augmented_assignment attribute identifier identifier integer else_clause block expression_statement assignment identifier integer while_statement comparison_operator identifier integer block expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier identifier while_statement comparison_operator binary_operator identifier integer identifier block expression_statement augmented_assignment identifier integer expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier binary_operator identifier integer binary_operator parenthesized_expression binary_operator binary_operator identifier integer identifier integer expression_statement augmented_assignment identifier integer expression_statement augmented_assignment attribute identifier identifier integer if_statement comparison_operator call identifier argument_list identifier integer block break_statement
handling missing incoming log data
def dash_example_1_view(request, template_name="demo_six.html", **kwargs): 'Example view that inserts content into the dash context passed to the dash application' context = {} dash_context = request.session.get("django_plotly_dash", dict()) dash_context['django_to_dash_context'] = "I am Dash receiving context from Django" request.session['django_plotly_dash'] = dash_context return render(request, template_name=template_name, context=context)
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end dictionary_splat_pattern identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier dictionary expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end call identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end identifier return_statement call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier
Example view that inserts content into the dash context passed to the dash application
def renderer(name): try: if name not in Store.renderers: extension(name) return Store.renderers[name] except ImportError: msg = ('Could not find a {name!r} renderer, available renderers are: {available}.') available = ', '.join(repr(k) for k in Store.renderers) raise ImportError(msg.format(name=name, available=available))
module function_definition identifier parameters identifier block try_statement block if_statement comparison_operator identifier attribute identifier identifier block expression_statement call identifier argument_list identifier return_statement subscript attribute identifier identifier identifier except_clause identifier block expression_statement assignment identifier parenthesized_expression string string_start string_content string_end expression_statement assignment identifier call attribute string string_start string_content string_end identifier generator_expression call identifier argument_list identifier for_in_clause identifier attribute identifier identifier raise_statement call identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier
Helper utility to access the active renderer for a given extension.
def make_dict_config(graph): formatters = {} handlers = {} loggers = {} formatters["ExtraFormatter"] = make_extra_console_formatter(graph) handlers["console"] = make_stream_handler(graph, formatter="ExtraFormatter") if enable_loggly(graph): formatters["JSONFormatter"] = make_json_formatter(graph) handlers["LogglyHTTPSHandler"] = make_loggly_handler(graph, formatter="JSONFormatter") loggers[""] = { "handlers": handlers.keys(), "level": graph.config.logging.level, } loggers.update(make_library_levels(graph)) return dict( version=1, disable_existing_loggers=False, formatters=formatters, handlers=handlers, loggers=loggers, )
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary expression_statement assignment identifier dictionary expression_statement assignment identifier dictionary expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list identifier expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list identifier keyword_argument identifier string string_start string_content string_end if_statement call identifier argument_list identifier block expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list identifier expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list identifier keyword_argument identifier string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_end dictionary pair string string_start string_content string_end call attribute identifier identifier argument_list pair string string_start string_content string_end attribute attribute attribute identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier return_statement call identifier argument_list keyword_argument identifier integer keyword_argument identifier false keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
Build a dictionary configuration from conventions and configuration.
def connect(self, callback=None, timeout=None): if hasattr(self, '_connecting_future') and not self._connecting_future.done(): future = self._connecting_future else: if hasattr(self, '_connecting_future'): self._connecting_future.exception() future = tornado.concurrent.Future() self._connecting_future = future self._connect(timeout=timeout) if callback is not None: def handle_future(future): response = future.result() self.io_loop.add_callback(callback, response) future.add_done_callback(handle_future) return future
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none block if_statement boolean_operator call identifier argument_list identifier string string_start string_content string_end not_operator call attribute attribute identifier identifier identifier argument_list block expression_statement assignment identifier attribute identifier identifier else_clause block if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier if_statement comparison_operator identifier none block function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Connect to the IPC socket
def start_recording(self): self._recording = True self._stop_recording.clear() self._source.start()
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier true expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list
Start recording from the audio source.
def _mk_tree(runas='root'): basedir = tempfile.mkdtemp() paths = ['BUILD', 'RPMS', 'SOURCES', 'SPECS', 'SRPMS'] for path in paths: full = os.path.join(basedir, path) __salt__['file.makedirs_perms'](name=full, user=runas, group='mock') return basedir
module function_definition identifier parameters default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list 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 for_statement identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement call subscript identifier string string_start string_content string_end argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end return_statement identifier
Create the rpm build tree
def _kde_support(bin_range, bw, gridsize, cut, clip): kmin, kmax = bin_range[0] - bw * cut, bin_range[1] + bw * cut if isfinite(clip[0]): kmin = max(kmin, clip[0]) if isfinite(clip[1]): kmax = min(kmax, clip[1]) return np.linspace(kmin, kmax, gridsize)
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement assignment pattern_list identifier identifier expression_list binary_operator subscript identifier integer binary_operator identifier identifier binary_operator subscript identifier integer binary_operator identifier identifier if_statement call identifier argument_list subscript identifier integer block expression_statement assignment identifier call identifier argument_list identifier subscript identifier integer if_statement call identifier argument_list subscript identifier integer block expression_statement assignment identifier call identifier argument_list identifier subscript identifier integer return_statement call attribute identifier identifier argument_list identifier identifier identifier
Establish support for a kernel density estimate.
def _is_pattern_match(re_pattern, s): match = re.match(re_pattern, s, re.I) return match.group() == s if match else False
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier attribute identifier identifier return_statement conditional_expression comparison_operator call attribute identifier identifier argument_list identifier identifier false
Check if a re pattern expression matches an entire string.
def _filter_names(names): names = [n for n in names if n not in EXCLUDE_NAMES] for pattern in EXCLUDE_PATTERNS: names = [n for n in names if (not fnmatch.fnmatch(n, pattern)) and (not n.endswith('.py'))] return names
module function_definition identifier parameters identifier block expression_statement assignment identifier list_comprehension identifier for_in_clause identifier identifier if_clause comparison_operator identifier identifier for_statement identifier identifier block expression_statement assignment identifier list_comprehension identifier for_in_clause identifier identifier if_clause boolean_operator parenthesized_expression not_operator call attribute identifier identifier argument_list identifier identifier parenthesized_expression not_operator call attribute identifier identifier argument_list string string_start string_content string_end return_statement identifier
Given a list of file names, return those names that should be copied.
def _iterslice(self, slice): indices = range(*slice.indices(len(self._records))) if self.is_attached(): rows = self._enum_attached_rows(indices) if slice.step is not None and slice.step < 0: rows = reversed(list(rows)) else: rows = zip(indices, self._records[slice]) fields = self.fields for i, row in rows: yield Record._make(fields, row, self, i)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list list_splat call attribute identifier identifier argument_list call identifier argument_list attribute identifier identifier if_statement call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement boolean_operator comparison_operator attribute identifier identifier none comparison_operator attribute identifier identifier integer block expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier else_clause block expression_statement assignment identifier call identifier argument_list identifier subscript attribute identifier identifier identifier expression_statement assignment identifier attribute identifier identifier for_statement pattern_list identifier identifier identifier block expression_statement yield call attribute identifier identifier argument_list identifier identifier identifier identifier
Yield records from a slice index.
def main(): __async__ = True logging.basicConfig(format="%(levelname)-10s %(message)s", level=logging.DEBUG) if len(sys.argv) != 2: logging.error("Must specify configuration file") sys.exit() config = configparser.ConfigParser() config.read(sys.argv[1]) password = config.get('default', 'password') if __async__: client = Client(config.get('default', 'host'), config.getint('default', 'port'), password, _callback) else: client = Client(config.get('default', 'host'), config.getint('default', 'port'), password) status = client.messages() msg = status[0] print(msg) print(client.mp3(msg['sha'].encode('utf-8'))) while True: continue
module function_definition identifier parameters block expression_statement assignment identifier true expression_statement call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier attribute identifier identifier if_statement comparison_operator call identifier argument_list attribute identifier identifier integer block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list subscript attribute identifier identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end if_statement identifier block expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier identifier else_clause block expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier subscript identifier integer expression_statement call identifier argument_list identifier expression_statement call identifier argument_list call attribute identifier identifier argument_list call attribute subscript identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end while_statement true block continue_statement
Show example using the API.
def action_decorator(name): def decorator(cls): action_decorators.append((name, cls)) return cls return decorator
module function_definition identifier parameters identifier block function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list tuple identifier identifier return_statement identifier return_statement identifier
Decorator to register an action decorator
def improve(): with open(settings.HOSTS_FILE, "r+") as hosts_file: contents = hosts_file.read() if not settings.START_TOKEN in contents and not settings.END_TOKEN in contents: hosts_file.write(settings.START_TOKEN + "\n") for site in set(settings.DISTRACTORS): hosts_file.write("{0}\t{1}\n".format(settings.REDIRECT_TO, site)) for sub_domain in settings.SUB_DOMAINS: hosts_file.write("{0}\t{1}.{2}\n".format(settings.REDIRECT_TO, sub_domain, site)) hosts_file.write(settings.END_TOKEN + "\n") reset_network("Concentration is now improved :D!")
module function_definition identifier parameters block with_statement with_clause with_item as_pattern call identifier argument_list attribute identifier identifier string string_start string_content string_end as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement boolean_operator not_operator comparison_operator attribute identifier identifier identifier not_operator comparison_operator attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator attribute identifier identifier string string_start string_content escape_sequence string_end for_statement identifier call identifier argument_list attribute identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content escape_sequence escape_sequence string_end identifier argument_list attribute identifier identifier identifier for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content escape_sequence escape_sequence string_end identifier argument_list attribute identifier identifier identifier identifier expression_statement call attribute identifier identifier argument_list binary_operator attribute identifier identifier string string_start string_content escape_sequence string_end expression_statement call identifier argument_list string string_start string_content string_end
Disables access to websites that are defined as 'distractors
def check_signature(self): if not self.signature: return True signature_value = request.headers.get(self.signature, None) if signature_value: validator = 'check_' + re.sub(r'[-]', '_', self.signature).lower() check_signature = getattr(signatures, validator) if check_signature(signature_value, request.data): return True return False
module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block return_statement true expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier none if_statement identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end call attribute call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end attribute identifier identifier identifier argument_list expression_statement assignment identifier call identifier argument_list identifier identifier if_statement call identifier argument_list identifier attribute identifier identifier block return_statement true return_statement false
Check signature of signed request.
def _ancestors_or_self( self, qname: Union[QualName, bool] = None) -> List[InstanceNode]: res = [] if qname and self.qual_name != qname else [self] return res + self.up()._ancestors(qname)
module function_definition identifier parameters identifier typed_default_parameter identifier type generic_type identifier type_parameter type identifier type identifier none type generic_type identifier type_parameter type identifier block expression_statement assignment identifier conditional_expression list boolean_operator identifier comparison_operator attribute identifier identifier identifier list identifier return_statement binary_operator identifier call attribute call attribute identifier identifier argument_list identifier argument_list identifier
XPath - return the list of receiver's ancestors including itself.
def skip_pickle_inject(app, what, name, obj, skip, options): if name.endswith('._raw_slave'): return True return None
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block if_statement call attribute identifier identifier argument_list string string_start string_content string_end block return_statement true return_statement none
skip global wrapper._raw_slave names used only for pickle support
def _validate_output_data( self, original_res, serialized_res, formatted_res, request): if self._is_doc_request(request): return else: return super(DocumentedResource, self)._validate_output_data( original_res, serialized_res, formatted_res, request)
module function_definition identifier parameters identifier identifier identifier identifier identifier block if_statement call attribute identifier identifier argument_list identifier block return_statement else_clause block return_statement call attribute call identifier argument_list identifier identifier identifier argument_list identifier identifier identifier identifier
Override to not validate doc output.
def wordcount(text): bannedwords = read_file('stopwords.txt') wordcount = {} separated = separate(text) for word in separated: if word not in bannedwords: if not wordcount.has_key(word): wordcount[word] = 1 else: wordcount[word] += 1 return wordcount
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list string string_start string_content string_end expression_statement assignment identifier dictionary expression_statement assignment identifier call identifier argument_list identifier for_statement identifier identifier block if_statement comparison_operator identifier identifier block if_statement not_operator call attribute identifier identifier argument_list identifier block expression_statement assignment subscript identifier identifier integer else_clause block expression_statement augmented_assignment subscript identifier identifier integer return_statement identifier
Returns the count of the words in a file.
def verify_connectivity(config): logger.debug("Verifying Connectivity") ic = InsightsConnection(config) try: branch_info = ic.get_branch_info() except requests.ConnectionError as e: logger.debug(e) logger.debug("Failed to connect to satellite") return False except LookupError as e: logger.debug(e) logger.debug("Failed to parse response from satellite") return False try: remote_leaf = branch_info['remote_leaf'] return remote_leaf except LookupError as e: logger.debug(e) logger.debug("Failed to find accurate branch_info") return False
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list except_clause as_pattern attribute identifier identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement false except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement false try_statement block expression_statement assignment identifier subscript identifier string string_start string_content string_end return_statement identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement false
Verify connectivity to satellite server
def _raise_document_too_large(operation, doc_size, max_size): if operation == "insert": raise DocumentTooLarge("BSON document too large (%d bytes)" " - the connected server supports" " BSON document sizes up to %d" " bytes." % (doc_size, max_size)) else: raise DocumentTooLarge("%r command document too large" % (operation,))
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator identifier string string_start string_content string_end block raise_statement call identifier argument_list binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end tuple identifier identifier else_clause block raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier
Internal helper for raising DocumentTooLarge.
def _convert_addrinfo(cls, results: List[tuple]) -> Iterable[AddressInfo]: for result in results: family = result[0] address = result[4] ip_address = address[0] if family == socket.AF_INET6: flow_info = address[2] control_id = address[3] else: flow_info = None control_id = None yield AddressInfo(ip_address, family, flow_info, control_id)
module function_definition identifier parameters identifier typed_parameter identifier type generic_type identifier type_parameter type identifier type generic_type identifier type_parameter type identifier block for_statement identifier identifier block expression_statement assignment identifier subscript identifier integer expression_statement assignment identifier subscript identifier integer expression_statement assignment identifier subscript identifier integer if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier subscript identifier integer expression_statement assignment identifier subscript identifier integer else_clause block expression_statement assignment identifier none expression_statement assignment identifier none expression_statement yield call identifier argument_list identifier identifier identifier identifier
Convert the result list to address info.
def grep(source, regex, stop_on_first=False): loader = ClassLoader(source, max_cache=-1) r = re.compile(regex) def _matches(constant): return r.match(constant.value) for klass in loader.classes: it = loader.search_constant_pool(path=klass, type_=UTF8, f=_matches) if next(it, None): print(klass) if stop_on_first: break
module function_definition identifier parameters identifier identifier default_parameter identifier false block expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier unary_operator integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier function_definition identifier parameters identifier block return_statement call attribute identifier identifier argument_list attribute identifier identifier for_statement identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier if_statement call identifier argument_list identifier none block expression_statement call identifier argument_list identifier if_statement identifier block break_statement
Grep the constant pool of all classes in source.
def doc_dict(self): doc = { 'type': self.__class__.__name__, 'description': self.description, 'default': self.default, 'required': self.required } if hasattr(self, 'details'): doc['detailed_description'] = self.details return doc
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end attribute attribute identifier identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier return_statement identifier
Returns the documentation dictionary for this argument.
def rgb256(r, g, b): grey = False poss = True step = 2.5 while poss: if r < step or g < step or b < step: grey = r < step and g < step and b < step poss = False step += 42.5 if grey: colour = 232 + int(float(sum([r, g, b]) / 33.0)) else: colour = sum([16] + [int (6 * float(val) / 256) * mod for val, mod in ((r, 36), (g, 6), (b, 1))]) return sequence('m', fields=3)(38, 5, colour)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier false expression_statement assignment identifier true expression_statement assignment identifier float while_statement identifier block if_statement boolean_operator boolean_operator comparison_operator identifier identifier comparison_operator identifier identifier comparison_operator identifier identifier block expression_statement assignment identifier boolean_operator boolean_operator comparison_operator identifier identifier comparison_operator identifier identifier comparison_operator identifier identifier expression_statement assignment identifier false expression_statement augmented_assignment identifier float if_statement identifier block expression_statement assignment identifier binary_operator integer call identifier argument_list call identifier argument_list binary_operator call identifier argument_list list identifier identifier identifier float else_clause block expression_statement assignment identifier call identifier argument_list binary_operator list integer list_comprehension binary_operator call identifier argument_list binary_operator binary_operator integer call identifier argument_list identifier integer identifier for_in_clause pattern_list identifier identifier tuple tuple identifier integer tuple identifier integer tuple identifier integer return_statement call call identifier argument_list string string_start string_content string_end keyword_argument identifier integer argument_list integer integer identifier
Convert an RGB colour to 256 colour ANSI graphics.
def derived_from_all(self, identities: List[QualName]) -> MutableSet[QualName]: if not identities: return set() res = self.derived_from(identities[0]) for id in identities[1:]: res &= self.derived_from(id) return res
module function_definition identifier parameters identifier typed_parameter identifier type generic_type identifier type_parameter type identifier type generic_type identifier type_parameter type identifier block if_statement not_operator identifier block return_statement call identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier integer for_statement identifier subscript identifier slice integer block expression_statement augmented_assignment identifier call attribute identifier identifier argument_list identifier return_statement identifier
Return list of identities transitively derived from all `identity`.
def isfile(self, version=None, *args, **kwargs): version = _process_version(self, version) path = self.get_version_path(version) self.authority.fs.isfile(path, *args, **kwargs)
module function_definition identifier parameters identifier default_parameter identifier none list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier list_splat identifier dictionary_splat identifier
Check whether the path exists and is a file
def register_subclass(cls): key = cls.interface_type, cls.resource_class if key in _SUBCLASSES: raise ValueError('Class already registered for %s and %s' % key) _SUBCLASSES[(cls.interface_type, cls.resource_class)] = cls _INTERFACE_TYPES.add(cls.interface_type) _RESOURCE_CLASSES[cls.interface_type].add(cls.resource_class) if cls.is_rc_optional: if cls.interface_type in _DEFAULT_RC: raise ValueError('Default already specified for %s' % cls.interface_type) _DEFAULT_RC[cls.interface_type] = cls.resource_class return cls
module function_definition identifier parameters identifier block expression_statement assignment identifier expression_list attribute identifier identifier attribute identifier identifier if_statement comparison_operator identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement assignment subscript identifier tuple attribute identifier identifier attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute subscript identifier attribute identifier identifier identifier argument_list attribute identifier identifier if_statement attribute identifier identifier block if_statement comparison_operator attribute identifier identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier expression_statement assignment subscript identifier attribute identifier identifier attribute identifier identifier return_statement identifier
Register a subclass for a given interface type and resource class.
def _send_command(self, command): if self.status is None or self.status.media_session_id is None: self.logger.warning( "%s command requested but no session is active.", command[MESSAGE_TYPE]) return command['mediaSessionId'] = self.status.media_session_id self.send_message(command, inc_session_id=True)
module function_definition identifier parameters identifier identifier block if_statement boolean_operator comparison_operator attribute identifier identifier none comparison_operator attribute attribute identifier identifier identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end subscript identifier identifier return_statement expression_statement assignment subscript identifier string string_start string_content string_end attribute attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier true
Send a command to the Chromecast on media channel.
def xy_time(self) -> Iterator[Tuple[float, float, float]]: iterator = iter(zip(self.coords, self.timestamp)) while True: next_ = next(iterator, None) if next_ is None: return coords, time = next_ yield (coords[0], coords[1], time.to_pydatetime().timestamp())
module function_definition identifier parameters identifier type generic_type identifier type_parameter type generic_type identifier type_parameter type identifier type identifier type identifier block expression_statement assignment identifier call identifier argument_list call identifier argument_list attribute identifier identifier attribute identifier identifier while_statement true block expression_statement assignment identifier call identifier argument_list identifier none if_statement comparison_operator identifier none block return_statement expression_statement assignment pattern_list identifier identifier identifier expression_statement yield tuple subscript identifier integer subscript identifier integer call attribute call attribute identifier identifier argument_list identifier argument_list
Iterates on longitudes, latitudes and timestamps.
def replace_all(text, dic): for i, j in dic.iteritems(): text = text.replace(i, j) return text
module function_definition identifier parameters identifier identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier return_statement identifier
Takes a string and dictionary. replaces all occurrences of i with j
def create_volume(self, project_id, plan, size, facility, label=""): try: return self.manager.create_volume(project_id, label, plan, size, facility) except packet.baseapi.Error as msg: raise PacketManagerException(msg)
module function_definition identifier parameters identifier identifier identifier identifier identifier default_parameter identifier string string_start string_end block try_statement block return_statement call attribute attribute identifier identifier identifier argument_list identifier identifier identifier identifier identifier except_clause as_pattern attribute attribute identifier identifier identifier as_pattern_target identifier block raise_statement call identifier argument_list identifier
Creates a new volume.
def background_thread(): count = 0 while True: socketio.sleep(10) count += 1 socketio.emit('my_response', {'data': 'Server generated event', 'count': count}, namespace='/test')
module function_definition identifier parameters block expression_statement assignment identifier integer while_statement true block expression_statement call attribute identifier identifier argument_list integer expression_statement augmented_assignment identifier integer expression_statement call attribute identifier identifier argument_list 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 identifier keyword_argument identifier string string_start string_content string_end
Example of how to send server generated events to clients.
def ls_cmd(context, before, status): runs = context.obj['store'].analyses( status=status, deleted=False, before=parse_date(before) if before else None, ).limit(30) for run_obj in runs: if run_obj.status == 'pending': message = f"{run_obj.id} | {run_obj.family} [{run_obj.status.upper()}]" else: message = (f"{run_obj.id} | {run_obj.family} {run_obj.started_at.date()} " f"[{run_obj.type.upper()}/{run_obj.status.upper()}]") if run_obj.status == 'running': message = click.style(f"{message} - {run_obj.progress * 100}/100", fg='blue') elif run_obj.status == 'completed': message = click.style(f"{message} - {run_obj.completed_at}", fg='green') elif run_obj.status == 'failed': message = click.style(message, fg='red') print(message)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute call attribute subscript attribute identifier identifier string string_start string_content string_end identifier argument_list keyword_argument identifier identifier keyword_argument identifier false keyword_argument identifier conditional_expression call identifier argument_list identifier identifier none identifier argument_list integer for_statement identifier identifier block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier string string_start interpolation attribute identifier identifier string_content interpolation attribute identifier identifier string_content interpolation call attribute attribute identifier identifier identifier argument_list string_content string_end else_clause block expression_statement assignment identifier parenthesized_expression concatenated_string string string_start interpolation attribute identifier identifier string_content interpolation attribute identifier identifier string_content interpolation call attribute attribute identifier identifier identifier argument_list string_content string_end string string_start string_content interpolation call attribute attribute identifier identifier identifier argument_list string_content interpolation call attribute attribute identifier identifier identifier argument_list string_content string_end if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start interpolation identifier string_content interpolation binary_operator attribute identifier identifier integer string_content string_end keyword_argument identifier string string_start string_content string_end elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start interpolation identifier string_content interpolation attribute identifier identifier string_end keyword_argument identifier string string_start string_content string_end elif_clause comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end expression_statement call identifier argument_list identifier
Display recent logs for analyses.
def int2str(num, radix=10, alphabet=BASE85): return NumConv(radix, alphabet).int2str(num)
module function_definition identifier parameters identifier default_parameter identifier integer default_parameter identifier identifier block return_statement call attribute call identifier argument_list identifier identifier identifier argument_list identifier
helper function for quick base conversions from integers to strings
def _find_usages_vpn_gateways(self): vpngws = self.conn.describe_vpn_gateways(Filters=[ { 'Name': 'state', 'Values': [ 'available', 'pending' ] } ])['VpnGateways'] self.limits['Virtual private gateways']._add_current_usage( len(vpngws), aws_type='AWS::EC2::VPNGateway' )
module function_definition identifier parameters identifier block expression_statement assignment identifier subscript call attribute attribute identifier identifier identifier argument_list keyword_argument identifier list dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement call attribute subscript attribute identifier identifier string string_start string_content string_end identifier argument_list call identifier argument_list identifier keyword_argument identifier string string_start string_content string_end
find usage of vpn gateways
def _resolve_workspace(self): if self.workspace is None: self.workspace = self.resolver.workspace_from_url(self.mets_url, baseurl=self.src_dir, download=self.download) self.mets = self.workspace.mets
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute attribute identifier identifier identifier
Clone workspace from mets_url unless workspace was provided.
def area(poly): if len(poly) < 3: return 0 total = [0, 0, 0] num = len(poly) for i in range(num): vi1 = poly[i] vi2 = poly[(i+1) % num] prod = np.cross(vi1, vi2) total[0] += prod[0] total[1] += prod[1] total[2] += prod[2] if total == [0, 0, 0]: return 0 result = np.dot(total, unit_normal(poly[0], poly[1], poly[2])) return abs(result/2)
module function_definition identifier parameters identifier block if_statement comparison_operator call identifier argument_list identifier integer block return_statement integer expression_statement assignment identifier list integer integer integer expression_statement assignment identifier call identifier argument_list identifier for_statement identifier call identifier argument_list identifier block expression_statement assignment identifier subscript identifier identifier expression_statement assignment identifier subscript identifier binary_operator parenthesized_expression binary_operator identifier integer identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement augmented_assignment subscript identifier integer subscript identifier integer expression_statement augmented_assignment subscript identifier integer subscript identifier integer expression_statement augmented_assignment subscript identifier integer subscript identifier integer if_statement comparison_operator identifier list integer integer integer block return_statement integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier call identifier argument_list subscript identifier integer subscript identifier integer subscript identifier integer return_statement call identifier argument_list binary_operator identifier integer
Area of a polygon poly
def paste( self ): text = nativestring(QApplication.clipboard().text()) for tag in text.split(','): tag = tag.strip() if ( self.isTagValid(tag) ): self.addTag(tag)
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list call attribute call attribute identifier identifier argument_list identifier argument_list for_statement identifier call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement parenthesized_expression call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier
Pastes text from the clipboard.
def write_versions(dirs, config=None, is_wrapper=False): out_file = _get_program_file(dirs) if is_wrapper: assert utils.file_exists(out_file), "Failed to create program versions from VM" elif out_file is None: for p in _get_versions(config): print("{program},{version}".format(**p)) else: with open(out_file, "w") as out_handle: for p in _get_versions(config): out_handle.write("{program},{version}\n".format(**p)) return out_file
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier false block expression_statement assignment identifier call identifier argument_list identifier if_statement identifier block assert_statement call attribute identifier identifier argument_list identifier string string_start string_content string_end elif_clause comparison_operator identifier none block for_statement identifier call identifier argument_list identifier block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list dictionary_splat identifier else_clause block with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block for_statement identifier call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list dictionary_splat identifier return_statement identifier
Write CSV file with versions used in analysis pipeline.
def ENUM_CONSTANT_DECL(self, cursor): name = cursor.displayname value = cursor.enum_value pname = self.get_unique_name(cursor.semantic_parent) parent = self.get_registered(pname) obj = typedesc.EnumValue(name, value, parent) parent.add_value(obj) return obj
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 call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Gets the enumeration values
def date(self, date): self._occurrence_data['date'] = self._utils.format_datetime( date, date_format='%Y-%m-%dT%H:%M:%SZ' )
module function_definition identifier parameters identifier identifier block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end
Set File Occurrence date.
def _multi_string_put_transform(cls, item, **kwargs): if isinstance(item, list): return item elif isinstance(item, six.string_types): if item.lower() == 'not defined': return None else: return item.split(',') else: return 'Invalid Value'
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block if_statement call identifier argument_list identifier identifier block return_statement identifier elif_clause call identifier argument_list identifier attribute identifier identifier block if_statement comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end block return_statement none else_clause block return_statement call attribute identifier identifier argument_list string string_start string_content string_end else_clause block return_statement string string_start string_content string_end
transform for a REG_MULTI_SZ to properly handle "Not Defined"
def most_frequent(self, k, inplace=False): vocabulary = self.vocabulary.most_frequent(k) vectors = np.asarray([self[w] for w in vocabulary]) if inplace: self.vocabulary = vocabulary self.vectors = vectors return self return Embedding(vectors=vectors, vocabulary=vocabulary)
module function_definition identifier parameters identifier identifier default_parameter identifier false block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list list_comprehension subscript identifier identifier for_in_clause identifier identifier if_statement identifier block expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier return_statement identifier return_statement call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier
Only most frequent k words to be included in the embeddings.
def run_guest(): global GUEST_USERID global GUEST_PROFILE global GUEST_VCPUS global GUEST_MEMORY global GUEST_ROOT_DISK_SIZE global DISK_POOL global IMAGE_PATH global IMAGE_OS_VERSION global GUEST_IP_ADDR global GATEWAY global CIDR global VSWITCH_NAME network_info = {'ip_addr': GUEST_IP_ADDR, 'gateway_addr': GATEWAY, 'cidr': CIDR, 'vswitch_name': VSWITCH_NAME} disks_list = [{'size': '%ig' % GUEST_ROOT_DISK_SIZE, 'is_boot_disk': True, 'disk_pool': DISK_POOL}] _run_guest(GUEST_USERID, IMAGE_PATH, IMAGE_OS_VERSION, GUEST_PROFILE, GUEST_VCPUS, GUEST_MEMORY, network_info, disks_list)
module function_definition identifier parameters block global_statement identifier global_statement identifier global_statement identifier global_statement identifier global_statement identifier global_statement identifier global_statement identifier global_statement identifier global_statement identifier global_statement identifier global_statement identifier global_statement identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier expression_statement assignment identifier list dictionary pair string string_start string_content string_end binary_operator string string_start string_content string_end identifier pair string string_start string_content string_end true pair string string_start string_content string_end identifier expression_statement call identifier argument_list identifier identifier identifier identifier identifier identifier identifier identifier
A sample for quick deploy and start a virtual guest.
def update_default_output_dir(self): if self.scenario_directory_radio.isChecked(): self.output_directory.setText(self.source_directory.text())
module function_definition identifier parameters identifier block if_statement call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list
Update output dir if set to default.
def main(): parser = argparse.ArgumentParser() parser.add_argument('--config_file', dest='config_file', help='Config file to be used in the' + 'run.', type=str, required=True, default=None) Job.Runner.addToilOptions(parser) params = parser.parse_args() START = Job.wrapJobFn(parse_config_file, params.config_file).encapsulate() Job.Runner.startToil(START, params) return None
module function_definition identifier parameters block 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 keyword_argument identifier string string_start string_content string_end keyword_argument identifier binary_operator string string_start string_content string_end string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier true keyword_argument identifier none expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier return_statement none
This is the main function for the UCSC Precision Immuno pipeline.
def _flatten_up_to_token(self, token): if token.is_group: token = next(token.flatten()) for t in self._curr_stmt.flatten(): if t == token: break yield t
module function_definition identifier parameters identifier identifier block if_statement attribute identifier identifier block expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list for_statement identifier call attribute attribute identifier identifier identifier argument_list block if_statement comparison_operator identifier identifier block break_statement expression_statement yield identifier
Yields all tokens up to token but excluding current.
def context(self): t = self.schema_term if not t: return {} sql_columns = [] all_columns = [] for i, c in enumerate(t.children): if c.term_is("Table.Column"): p = c.all_props if p.get('sqlselect'): sql_columns.append(p.get('sqlselect')) all_columns.append(c.name) return { 'SQL_COLUMNS': ', '.join(sql_columns), 'ALL_COLUMNS': ', '.join(all_columns) }
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier if_statement not_operator identifier block return_statement dictionary expression_statement assignment identifier list expression_statement assignment identifier list for_statement pattern_list identifier identifier call identifier argument_list attribute identifier identifier block if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier attribute identifier identifier if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list attribute identifier identifier return_statement dictionary pair string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list identifier pair string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list identifier
Build the interpolation context from the schemas
def setproxy(ctx, proxy_account, account): print_tx(ctx.bitshares.set_proxy(proxy_account, account=account))
module function_definition identifier parameters identifier identifier identifier block expression_statement call identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier identifier
Set the proxy account for an account
def _scale_shape(dshape, scale = (1,1,1)): nshape = np.round(np.array(dshape) * np.array(scale)) return tuple(nshape.astype(np.int))
module function_definition identifier parameters identifier default_parameter identifier tuple integer integer integer block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier return_statement call identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier
returns the shape after scaling (should be the same as ndimage.zoom
def _split(string, splitters): part = '' for character in string: if character in splitters: yield part part = '' else: part += character yield part
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier string string_start string_end for_statement identifier identifier block if_statement comparison_operator identifier identifier block expression_statement yield identifier expression_statement assignment identifier string string_start string_end else_clause block expression_statement augmented_assignment identifier identifier expression_statement yield identifier
Splits a string into parts at multiple characters
def read_array(self, key, start=None, stop=None): import tables node = getattr(self.group, key) attrs = node._v_attrs transposed = getattr(attrs, 'transposed', False) if isinstance(node, tables.VLArray): ret = node[0][start:stop] else: dtype = getattr(attrs, 'value_type', None) shape = getattr(attrs, 'shape', None) if shape is not None: ret = np.empty(shape, dtype=dtype) else: ret = node[start:stop] if dtype == 'datetime64': ret = _set_tz(ret, getattr(attrs, 'tz', None), coerce=True) elif dtype == 'timedelta64': ret = np.asarray(ret, dtype='m8[ns]') if transposed: return ret.T else: return ret
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none block import_statement dotted_name identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end false if_statement call identifier argument_list identifier attribute identifier identifier block expression_statement assignment identifier subscript subscript identifier integer slice identifier identifier else_clause block expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end none expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end none if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier else_clause block expression_statement assignment identifier subscript identifier slice identifier identifier if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list identifier call identifier argument_list identifier string string_start string_content string_end none keyword_argument identifier true elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end if_statement identifier block return_statement attribute identifier identifier else_clause block return_statement identifier
read an array for the specified node (off of group
def authenticate(self, request, url_auth_token=None): try: return self.parse_token(url_auth_token) except TypeError: backend = "%s.%s" % (self.__module__, self.__class__.__name__) logger.exception("TypeError in %s, here's the traceback before " "Django swallows it:", backend) raise
module function_definition identifier parameters identifier identifier default_parameter identifier none block try_statement block return_statement call attribute identifier identifier argument_list identifier except_clause identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple attribute identifier identifier attribute attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end identifier raise_statement
Check the token and return the corresponding user.
def expand_idx_mimetype(type_): if isinstance(type_, unicode_type): match = __IDX_PATTERN.match(type_) return __IDX_MAPPING.get(match.group(1), type_) if match else type_ else: return type_
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement conditional_expression call attribute identifier identifier argument_list call attribute identifier identifier argument_list integer identifier identifier identifier else_clause block return_statement identifier
Returns long equivalent of type_, if available, otherwise type_ itself. Does not raise exceptions
def raises(cls, sender, attrname, error, args=ANYTHING, kwargs=ANYTHING): "An alternative constructor which raises the given error" def raise_error(): raise error return cls(sender, attrname, returns=Invoke(raise_error), args=ANYTHING, kwargs=ANYTHING)
module function_definition identifier parameters identifier identifier identifier identifier default_parameter identifier identifier default_parameter identifier identifier block expression_statement string string_start string_content string_end function_definition identifier parameters block raise_statement identifier return_statement call identifier argument_list identifier identifier keyword_argument identifier call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier
An alternative constructor which raises the given error
def populate(self, blueprint, documents): documents = self.finish(blueprint, documents) frames = [] for document in documents: meta_document = {} for field_name in blueprint._meta_fields: meta_document[field_name] = document[field_name] document.pop(field_name) frame = blueprint.get_frame_cls()(document) for key, value in meta_document.items(): setattr(frame, key, value) frames.append(frame) blueprint.on_fake(frames) frames = blueprint.get_frame_cls().insert_many(frames) blueprint.on_faked(frames) return frames
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier list for_statement identifier identifier block expression_statement assignment identifier dictionary for_statement identifier attribute identifier identifier block expression_statement assignment subscript identifier identifier subscript identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call call attribute identifier identifier argument_list argument_list identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement call identifier argument_list identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Populate the database with documents
def version(short): if short: print(get_system_spec()['raiden']) else: print(json.dumps( get_system_spec(), indent=2, ))
module function_definition identifier parameters identifier block if_statement identifier block expression_statement call identifier argument_list subscript call identifier argument_list string string_start string_content string_end else_clause block expression_statement call identifier argument_list call attribute identifier identifier argument_list call identifier argument_list keyword_argument identifier integer
Print version information and exit.
def generate_unit_triangles(image_width, image_height): h = math.sin(math.pi / 3) for x in range(-1, image_width): for y in range(int(image_height / h)): x_ = x if (y % 2 == 0) else x + 0.5 yield [(x_, y * h), (x_ + 1, y * h), (x_ + 0.5, (y + 1) * h)] yield [(x_ + 1, y * h), (x_ + 1.5, (y + 1) * h), (x_ + 0.5, (y + 1) * h)]
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator attribute identifier identifier integer for_statement identifier call identifier argument_list unary_operator integer identifier block for_statement identifier call identifier argument_list call identifier argument_list binary_operator identifier identifier block expression_statement assignment identifier conditional_expression identifier parenthesized_expression comparison_operator binary_operator identifier integer integer binary_operator identifier float expression_statement yield list tuple identifier binary_operator identifier identifier tuple binary_operator identifier integer binary_operator identifier identifier tuple binary_operator identifier float binary_operator parenthesized_expression binary_operator identifier integer identifier expression_statement yield list tuple binary_operator identifier integer binary_operator identifier identifier tuple binary_operator identifier float binary_operator parenthesized_expression binary_operator identifier integer identifier tuple binary_operator identifier float binary_operator parenthesized_expression binary_operator identifier integer identifier
Generate coordinates for a tiling of unit triangles.
def load_search_freq(fp=SEARCH_FREQ_JSON): try: with open(fp) as f: return Counter(json.load(f)) except FileNotFoundError: return Counter()
module function_definition identifier parameters default_parameter identifier identifier block try_statement block with_statement with_clause with_item as_pattern call identifier argument_list identifier as_pattern_target identifier block return_statement call identifier argument_list call attribute identifier identifier argument_list identifier except_clause identifier block return_statement call identifier argument_list
Load the search_freq from JSON file
def encodeRNA(seq_vec, maxlen=None, seq_align="start"): return encodeSequence(seq_vec, vocab=RNA, neutral_vocab="N", maxlen=maxlen, seq_align=seq_align, pad_value="N", encode_type="one_hot")
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier string string_start string_content string_end block return_statement call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end
Convert the RNA sequence into 1-hot-encoding numpy array as for encodeDNA
def _check_cooling_parameters(radiuscooling, scalecooling): if radiuscooling != "linear" and radiuscooling != "exponential": raise Exception("Invalid parameter for radiuscooling: " + radiuscooling) if scalecooling != "linear" and scalecooling != "exponential": raise Exception("Invalid parameter for scalecooling: " + scalecooling)
module function_definition identifier parameters identifier identifier block if_statement boolean_operator comparison_operator identifier string string_start string_content string_end comparison_operator identifier string string_start string_content string_end block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier if_statement boolean_operator comparison_operator identifier string string_start string_content string_end comparison_operator identifier string string_start string_content string_end block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier
Helper function to verify the cooling parameters of the training.
def _parse_mut(subs): if subs!="0": subs = [[subs.replace(subs[-2:], ""),subs[-2], subs[-1]]] return subs
module function_definition identifier parameters identifier block if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier list list call attribute identifier identifier argument_list subscript identifier slice unary_operator integer string string_start string_end subscript identifier unary_operator integer subscript identifier unary_operator integer return_statement identifier
Parse mutation tag from miraligner output
def on_after_build_all(self, builder, **extra): try: is_enabled = self.is_enabled(builder.build_flags) except AttributeError: is_enabled = self.is_enabled(builder.extra_flags) if not is_enabled: return reporter.report_generic('Starting HTML minification') for htmlfile in self.find_html_files(builder.destination_path): self.minify_file(htmlfile) reporter.report_generic('HTML minification finished')
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier except_clause identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier if_statement not_operator identifier block return_statement expression_statement call attribute identifier identifier argument_list string string_start string_content string_end for_statement identifier call attribute identifier identifier argument_list attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end
after-build-all lektor event
def _connect_callbacks(self): figure = self.get_figure() callback = partial(mpl_redraw_callback, tax=self) event_names = ('resize_event', 'draw_event') for event_name in event_names: figure.canvas.mpl_connect(event_name, callback)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier expression_statement assignment identifier tuple string string_start string_content string_end string string_start string_content string_end for_statement identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier
Connect resize matplotlib callbacks.
def replace_postgres_db(self, file_url): self.print_message("Replacing postgres database") if file_url: self.print_message("Sourcing data from online backup file '%s'" % file_url) source_file = self.download_file_from_url(self.args.source_app, file_url) elif self.databases['source']['name']: self.print_message("Sourcing data from database '%s'" % self.databases['source']['name']) source_file = self.dump_database() else: self.print_message("Sourcing data from local backup file %s" % self.args.file) source_file = self.args.file self.drop_database() self.create_database() source_file = self.unzip_file_if_necessary(source_file) self.print_message("Importing '%s' into database '%s'" % (source_file, self.databases['destination']['name'])) args = [ "pg_restore", "--no-acl", "--no-owner", "--dbname=%s" % self.databases['destination']['name'], source_file, ] args.extend(self.databases['destination']['args']) subprocess.check_call(args)
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end if_statement identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute attribute identifier identifier identifier identifier elif_clause subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list else_clause block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end attribute attribute identifier identifier identifier expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end binary_operator string string_start string_content string_end subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier
Replace postgres database with database from specified source.
def update_endpoint_group(self, endpoint_group, body=None): return self.put(self.endpoint_group_path % endpoint_group, body=body)
module function_definition identifier parameters identifier identifier default_parameter identifier none block return_statement call attribute identifier identifier argument_list binary_operator attribute identifier identifier identifier keyword_argument identifier identifier
Updates a VPN endpoint group.
def _get_socketpair(self): try: return self._cls_idle_socketpairs.pop() except IndexError: rsock, wsock = socket.socketpair() set_cloexec(rsock.fileno()) set_cloexec(wsock.fileno()) self._cls_all_sockets.extend((rsock, wsock)) return rsock, wsock
module function_definition identifier parameters identifier block try_statement block return_statement call attribute attribute identifier identifier identifier argument_list except_clause identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list expression_statement call identifier argument_list call attribute identifier identifier argument_list expression_statement call identifier argument_list call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list tuple identifier identifier return_statement expression_list identifier identifier
Return an unused socketpair, creating one if none exist.
def setup_catalog_mappings(portal): logger.info("*** Setup Catalog Mappings ***") at = api.get_tool("archetype_tool") for portal_type, catalogs in CATALOG_MAPPINGS: at.setCatalogsByType(portal_type, catalogs)
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end for_statement pattern_list identifier identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier
Setup portal_type -> catalog mappings
def decode(addr): hrpgot, data = bech32_decode(addr) if hrpgot not in BECH32_VERSION_SET: return (None, None) decoded = convertbits(data[1:], 5, 8, False) if decoded is None or len(decoded) < 2 or len(decoded) > 40: return (None, None) if data[0] > 16: return (None, None) if data[0] == 0 and len(decoded) != 20 and len(decoded) != 32: return (None, None) return (data[0], decoded)
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier if_statement comparison_operator identifier identifier block return_statement tuple none none expression_statement assignment identifier call identifier argument_list subscript identifier slice integer integer integer false if_statement boolean_operator boolean_operator comparison_operator identifier none comparison_operator call identifier argument_list identifier integer comparison_operator call identifier argument_list identifier integer block return_statement tuple none none if_statement comparison_operator subscript identifier integer integer block return_statement tuple none none if_statement boolean_operator boolean_operator comparison_operator subscript identifier integer integer comparison_operator call identifier argument_list identifier integer comparison_operator call identifier argument_list identifier integer block return_statement tuple none none return_statement tuple subscript identifier integer identifier
Decode a segwit address.
def parse(self, parser, xml): if xml.text is not None: matches = parser.RE_REFS.finditer(xml.text) if matches: for match in matches: self.references.append(match.group("reference")) for key in list(xml.keys()): self.attributes[key] = xml.get(key)
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier if_statement identifier block for_statement identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end for_statement identifier call identifier argument_list call attribute identifier identifier argument_list block expression_statement assignment subscript attribute identifier identifier identifier call attribute identifier identifier argument_list identifier
Parses the rawtext to extract contents and references.
def _section(cls, opts): if isinstance(cls.config, LuigiConfigParser): return False try: logging_config = cls.config['logging'] except (TypeError, KeyError, NoSectionError): return False logging.config.dictConfig(logging_config) return True
module function_definition identifier parameters identifier identifier block if_statement call identifier argument_list attribute identifier identifier identifier block return_statement false try_statement block expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end except_clause tuple identifier identifier identifier block return_statement false expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement true
Get logging settings from config file section "logging".
def term_regex(term): return re.compile(r'^{0}$'.format(re.escape(term)), re.IGNORECASE)
module function_definition identifier parameters identifier block return_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list identifier attribute identifier identifier
Returns a case-insensitive regex for searching terms
def _center_tile(self, position, size): x, y = position w, h = size return x + (self.cell_width - w) / 2, y + (self.cell_height - h) / 2
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment pattern_list identifier identifier identifier expression_statement assignment pattern_list identifier identifier identifier return_statement expression_list binary_operator identifier binary_operator parenthesized_expression binary_operator attribute identifier identifier identifier integer binary_operator identifier binary_operator parenthesized_expression binary_operator attribute identifier identifier identifier integer
Calculate the centre of a tile given the top-left corner and the size of the image.
def merge_report(self, otherself): self.notices += otherself.notices self.warnings += otherself.warnings self.errors += otherself.errors
module function_definition identifier parameters identifier identifier block expression_statement augmented_assignment attribute identifier identifier attribute identifier identifier expression_statement augmented_assignment attribute identifier identifier attribute identifier identifier expression_statement augmented_assignment attribute identifier identifier attribute identifier identifier
Merge another report into this one.
def hash(self, build_context) -> str: if self._hash is None: self.compute_hash(build_context) return self._hash
module function_definition identifier parameters identifier identifier type identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute identifier identifier argument_list identifier return_statement attribute identifier identifier
Return the hash of this target for caching purposes.
def listen(room): def onmessage(m): print(m) if m.admin or m.nick == r.user.name: return if "parrot" in m.msg.lower(): r.post_chat("ayy lmao") elif m.msg.lower() in ("lol", "lel", "kek"): r.post_chat("*kok") else: r.post_chat(re.sub(r"\blain\b", "purpleadmin", m.msg, re.I)) with Room(room) as r: r.user.change_nick("DumbParrot") r.add_listener("chat", onmessage) r.listen()
module function_definition identifier parameters identifier block function_definition identifier parameters identifier block expression_statement call identifier argument_list identifier if_statement boolean_operator attribute identifier identifier comparison_operator attribute identifier identifier attribute attribute identifier identifier identifier block return_statement if_statement comparison_operator string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end elif_clause comparison_operator call attribute attribute identifier identifier identifier argument_list tuple string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block 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 call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end attribute identifier identifier attribute identifier identifier with_statement with_clause with_item as_pattern call identifier argument_list identifier as_pattern_target 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 expression_statement call attribute identifier identifier argument_list
Open a volafile room and start listening to it
def check_MIC_ICV(data, mic_key, source, dest): assert len(data) > 12 ICV = data[-4:] MIC = data[-12:-4] data_clear = data[:-12] expected_ICV = pack("<I", crc32(data_clear + MIC) & 0xFFFFFFFF) if expected_ICV != ICV: raise ICVError() sa = mac2str(source) da = mac2str(dest) expected_MIC = michael(mic_key, da + sa + b"\x00" * 4 + data_clear) if expected_MIC != MIC: raise MICError() return data_clear
module function_definition identifier parameters identifier identifier identifier identifier block assert_statement comparison_operator call identifier argument_list identifier integer expression_statement assignment identifier subscript identifier slice unary_operator integer expression_statement assignment identifier subscript identifier slice unary_operator integer unary_operator integer expression_statement assignment identifier subscript identifier slice unary_operator integer expression_statement assignment identifier call identifier argument_list string string_start string_content string_end binary_operator call identifier argument_list binary_operator identifier identifier integer if_statement comparison_operator identifier identifier block raise_statement call identifier argument_list expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier binary_operator binary_operator binary_operator identifier identifier binary_operator string string_start string_content escape_sequence string_end integer identifier if_statement comparison_operator identifier identifier block raise_statement call identifier argument_list return_statement identifier
Check MIC, ICV & return the data from a decrypted TKIP packet
def get(self, url, params=None, **kwargs): return requests.get(url, params=params, headers=self.add_headers(**kwargs))
module function_definition identifier parameters identifier identifier default_parameter identifier none dictionary_splat_pattern identifier block return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier call attribute identifier identifier argument_list dictionary_splat identifier
Encapsulte requests.get to use this class instance header
def report(args): logger.info("reading sequeces") data = load_data(args.json) logger.info("create profile") data = make_profile(data, os.path.join(args.out, "profiles"), args) logger.info("create database") make_database(data, "seqcluster.db", args.out) logger.info("Done. Download https://github.com/lpantano/seqclusterViz/archive/master.zip to browse the output.")
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list identifier string string_start string_content string_end attribute identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end
Create report in html format
def new_cast_status(self, status): self.status = status if status: self.status_event.set()
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier identifier if_statement identifier block expression_statement call attribute attribute identifier identifier identifier argument_list
Called when a new status received from the Chromecast.
def rallyloader(self): if not self.target_system in self.rallyloader_by_sysid: self.rallyloader_by_sysid[self.target_system] = mavwp.MAVRallyLoader(self.settings.target_system, self.settings.target_component) return self.rallyloader_by_sysid[self.target_system]
module function_definition identifier parameters identifier block if_statement not_operator comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier attribute identifier identifier call attribute identifier identifier argument_list attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier return_statement subscript attribute identifier identifier attribute identifier identifier
rally loader by system ID
def to_jd(year, month, day): gy = year - 1 + EPOCH_GREGORIAN_YEAR if month != 20: m = 0 else: if isleap(gy + 1): m = -14 else: m = -15 return gregorian.to_jd(gy, 3, 20) + (19 * (month - 1)) + m + day
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier binary_operator binary_operator identifier integer identifier if_statement comparison_operator identifier integer block expression_statement assignment identifier integer else_clause block if_statement call identifier argument_list binary_operator identifier integer block expression_statement assignment identifier unary_operator integer else_clause block expression_statement assignment identifier unary_operator integer return_statement binary_operator binary_operator binary_operator call attribute identifier identifier argument_list identifier integer integer parenthesized_expression binary_operator integer parenthesized_expression binary_operator identifier integer identifier identifier
Determine Julian day from Bahai date
def _run(self): try: self.worker() except SystemExit as ex: if isinstance(ex.code, int): if ex.code is not None and ex.code != 0: self._shutdown( 'Exiting with non-zero exit code {exitcode}'.format( exitcode=ex.code), ex.code) else: self._shutdown( 'Exiting with message: {msg}'.format(msg=ex.code), 1) except Exception as ex: if self.detach: self._shutdown('Dying due to unhandled {cls}: {msg}'.format( cls=ex.__class__.__name__, msg=str(ex)), 127) else: raise self._shutdown('Shutting down normally')
module function_definition identifier parameters identifier block try_statement block expression_statement call attribute identifier identifier argument_list except_clause as_pattern identifier as_pattern_target identifier block if_statement call identifier argument_list attribute identifier identifier identifier block if_statement boolean_operator comparison_operator attribute identifier identifier none comparison_operator attribute identifier identifier integer block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier attribute identifier identifier attribute identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier attribute identifier identifier integer except_clause as_pattern identifier as_pattern_target identifier block if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier attribute attribute identifier identifier identifier keyword_argument identifier call identifier argument_list identifier integer else_clause block raise_statement expression_statement call attribute identifier identifier argument_list string string_start string_content string_end
Run the worker function with some custom exception handling.
def update_policy(self,cspDefaultHeaders): try: self.check_valid(cspDefaultHeaders) if self.inputs is not None: for p,l in self.inputs.items(): cspDefaultHeaders[p] = cspDefaultHeaders[p]+ list(set(self.inputs[p]) - set(cspDefaultHeaders[p])) return cspDefaultHeaders else: return self.inputs except Exception, e: raise
module function_definition identifier parameters identifier identifier block try_statement block expression_statement call attribute identifier identifier argument_list identifier if_statement comparison_operator attribute identifier identifier none block for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block expression_statement assignment subscript identifier identifier binary_operator subscript identifier identifier call identifier argument_list binary_operator call identifier argument_list subscript attribute identifier identifier identifier call identifier argument_list subscript identifier identifier return_statement identifier else_clause block return_statement attribute identifier identifier except_clause identifier identifier block raise_statement
add items to existing csp policies
def _outliers(self,x): outliers = self._tukey(x, threshold = 1.5) return np.size(outliers)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier float return_statement call attribute identifier identifier argument_list identifier
Compute number of outliers