code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def load_dict(self, dct): for k, v in dct.items(): setattr(self, k, v)
module function_definition identifier parameters identifier identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement call identifier argument_list identifier identifier identifier
Load a dictionary of configuration values.
def create(resource_path, previous_version=None, package='perch.migrations'): pkg, obj = resource_path.rsplit('.', 1) module = importlib.import_module(pkg) resource = getattr(module, obj) version = uuid4().hex target_module = importlib.import_module(package) target_dir = os.path.dirname(target_module.__file__) target_file = os.path.join(target_dir, resource.resource_type + '_' + version + '.py') with open(target_file, 'w') as f: f.write(MIGRATION_TEMPLATE.format( resource_path=resource_path, resource_type=resource.resource_type, version=version, previous_version=previous_version or '', )) return target_file
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier string string_start string_content string_end block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier attribute call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier binary_operator binary_operator binary_operator attribute identifier identifier string string_start string_content string_end identifier string string_start string_content string_end with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier boolean_operator identifier string string_start string_end return_statement identifier
Create a new migration
async def set_topic(self, topic): self.topic = topic try: if self.topicchannel: await client.edit_channel(self.topicchannel, topic=topic) except Exception as e: logger.exception(e)
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier identifier try_statement block if_statement attribute identifier identifier block expression_statement await call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier
Sets the topic for the topic channel
def do_for_dir(inws, begin): inws = os.path.abspath(inws) for wroot, wdirs, wfiles in os.walk(inws): for wfile in wfiles: if wfile.endswith('.html'): if 'autogen' in wroot: continue check_html(os.path.abspath(os.path.join(wroot, wfile)), begin)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier for_statement pattern_list identifier identifier identifier call attribute identifier identifier argument_list identifier block for_statement identifier identifier block if_statement call attribute identifier identifier argument_list string string_start string_content string_end block if_statement comparison_operator string string_start string_content string_end identifier block continue_statement expression_statement call identifier argument_list call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier identifier
do something in the directory.
def _cleanup(self): current_time = time.time() timeout = self._config.timeout if current_time - self._last_cleanup_time > timeout: self.store.cleanup(timeout) self._last_cleanup_time = current_time
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier attribute attribute identifier identifier identifier if_statement comparison_operator binary_operator identifier attribute identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier identifier
Cleanup the stored sessions
def delete(self, data=None): if not self.can_delete: raise JSSMethodNotAllowedError(self.__class__.__name__) if data: self.jss.delete(self.url, data) else: self.jss.delete(self.url)
module function_definition identifier parameters identifier default_parameter identifier none block if_statement not_operator attribute identifier identifier block raise_statement call identifier argument_list attribute attribute identifier identifier identifier if_statement identifier block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier
Delete this object from the JSS.
def _get_subscriptions_endpoint(self): s = self.settings() params = { 'access_token': self.app_access_token, } return ( GRAPH_ENDPOINT.format(f'{s["app_id"]}/subscriptions'), params, )
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier dictionary pair string string_start string_content string_end attribute identifier identifier return_statement tuple call attribute identifier identifier argument_list string string_start interpolation subscript identifier string string_start string_content string_end string_content string_end identifier
Generates the URL and tokens for the subscriptions endpoint
def generate_header_from_parent_header( compute_difficulty_fn: Callable[[BlockHeader, int], int], parent_header: BlockHeader, coinbase: Address, timestamp: Optional[int] = None, extra_data: bytes = b'') -> BlockHeader: if timestamp is None: timestamp = max(int(time.time()), parent_header.timestamp + 1) elif timestamp <= parent_header.timestamp: raise ValueError( "header.timestamp ({}) should be higher than" "parent_header.timestamp ({})".format( timestamp, parent_header.timestamp, ) ) header = BlockHeader( difficulty=compute_difficulty_fn(parent_header, timestamp), block_number=(parent_header.block_number + 1), gas_limit=compute_gas_limit( parent_header, gas_limit_floor=GENESIS_GAS_LIMIT, ), timestamp=timestamp, parent_hash=parent_header.hash, state_root=parent_header.state_root, coinbase=coinbase, extra_data=extra_data, ) return header
module function_definition identifier parameters typed_parameter identifier type generic_type identifier type_parameter type list identifier identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier typed_default_parameter identifier type generic_type identifier type_parameter type identifier none typed_default_parameter identifier type identifier string string_start string_end type identifier block if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list call identifier argument_list call attribute identifier identifier argument_list binary_operator attribute identifier identifier integer elif_clause comparison_operator identifier attribute 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 identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier call identifier argument_list identifier identifier keyword_argument identifier parenthesized_expression binary_operator attribute identifier identifier integer keyword_argument identifier call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier return_statement identifier
Generate BlockHeader from state_root and parent_header
def oauth_error_handler(f): @wraps(f) def inner(*args, **kwargs): try: return f(*args, **kwargs) except OAuthClientError as e: current_app.logger.warning(e.message, exc_info=True) return oauth2_handle_error( e.remote, e.response, e.code, e.uri, e.description ) except OAuthCERNRejectedAccountError as e: current_app.logger.warning(e.message, exc_info=True) flash(_('CERN account not allowed.'), category='danger') return redirect('/') except OAuthRejectedRequestError: flash(_('You rejected the authentication request.'), category='info') return redirect('/') except AlreadyLinkedError: flash(_('External service is already linked to another account.'), category='danger') return redirect(url_for('invenio_oauthclient_settings.index')) return inner
module function_definition identifier parameters identifier block decorated_definition decorator call identifier argument_list identifier function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block try_statement block return_statement call identifier argument_list list_splat identifier dictionary_splat identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier keyword_argument identifier true return_statement call identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier keyword_argument identifier true expression_statement call identifier argument_list call identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end return_statement call identifier argument_list string string_start string_content string_end except_clause identifier block expression_statement call identifier argument_list call identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end return_statement call identifier argument_list string string_start string_content string_end except_clause identifier block expression_statement call identifier argument_list call identifier argument_list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end return_statement call identifier argument_list call identifier argument_list string string_start string_content string_end return_statement identifier
Decorator to handle exceptions.
def initialize_processing(): need_initialize = False needed_algorithms = [ 'native:clip', 'gdal:cliprasterbyextent', 'native:union', 'native:intersection' ] if not QgsApplication.processingRegistry().algorithms(): need_initialize = True if not need_initialize: for needed_algorithm in needed_algorithms: if not QgsApplication.processingRegistry().algorithmById( needed_algorithm): need_initialize = True break if need_initialize: QgsApplication.processingRegistry().addProvider(QgsNativeAlgorithms()) processing.Processing.initialize()
module function_definition identifier parameters block expression_statement assignment identifier false 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 if_statement not_operator call attribute call attribute identifier identifier argument_list identifier argument_list block expression_statement assignment identifier true if_statement not_operator identifier block for_statement identifier identifier block if_statement not_operator call attribute call attribute identifier identifier argument_list identifier argument_list identifier block expression_statement assignment identifier true break_statement if_statement identifier block expression_statement call attribute call attribute identifier identifier argument_list identifier argument_list call identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list
Initializes processing, if it's not already been done
def channel_is_settled( self, participant1: Address, participant2: Address, block_identifier: BlockSpecification, channel_identifier: ChannelID, ) -> bool: try: channel_state = self._get_channel_state( participant1=participant1, participant2=participant2, block_identifier=block_identifier, channel_identifier=channel_identifier, ) except RaidenRecoverableError: return False return channel_state >= ChannelState.SETTLED
module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier type identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier except_clause identifier block return_statement false return_statement comparison_operator identifier attribute identifier identifier
Returns true if the channel is in a settled state, false otherwise.
def plot_pyro(calc_id=-1): import matplotlib.pyplot as p dstore = util.read(calc_id) sitecol = dstore['sitecol'] asset_risk = dstore['asset_risk'].value pyro, = numpy.where(dstore['multi_peril']['PYRO'] == 1) lons = sitecol.lons[pyro] lats = sitecol.lats[pyro] p.scatter(lons, lats, marker='o', color='red') building_pyro, = numpy.where(asset_risk['building-PYRO'] == 1) lons = sitecol.lons[building_pyro] lats = sitecol.lats[building_pyro] p.scatter(lons, lats, marker='.', color='green') p.show()
module function_definition identifier parameters default_parameter identifier unary_operator integer block import_statement aliased_import dotted_name identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier attribute subscript identifier string string_start string_content string_end identifier expression_statement assignment pattern_list identifier call attribute identifier identifier argument_list comparison_operator subscript subscript identifier string string_start string_content string_end string string_start string_content string_end integer expression_statement assignment identifier subscript attribute identifier identifier identifier expression_statement assignment identifier subscript attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement assignment pattern_list identifier call attribute identifier identifier argument_list comparison_operator subscript identifier string string_start string_content string_end integer expression_statement assignment identifier subscript attribute identifier identifier identifier expression_statement assignment identifier subscript attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list
Plot the pyroclastic cloud and the assets
def _muck_w_date(record): temp_d = datetime.datetime(int(record['Year']), int(record['Month']), int(record['Day']), int(record['Hour']) % 24, int(record['Minute']) % 60) d_off = int(record['Hour'])//24 if d_off > 0: temp_d += datetime.timedelta(days=d_off) return temp_d
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list subscript identifier string string_start string_content string_end call identifier argument_list subscript identifier string string_start string_content string_end call identifier argument_list subscript identifier string string_start string_content string_end binary_operator call identifier argument_list subscript identifier string string_start string_content string_end integer binary_operator call identifier argument_list subscript identifier string string_start string_content string_end integer expression_statement assignment identifier binary_operator call identifier argument_list subscript identifier string string_start string_content string_end integer if_statement comparison_operator identifier integer block expression_statement augmented_assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier return_statement identifier
muck with the date because EPW starts counting from 1 and goes to 24.
def sync_with_prompt_toolkit(self): self.editor_layout.update() window = self.window_arrangement.active_pt_window if window: self.application.layout.focus(window)
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier attribute attribute identifier identifier identifier if_statement identifier block expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list identifier
Update the prompt-toolkit Layout and FocusStack.
def whisper_lock_writes(self, cluster='main'): if not self.config.has_section(cluster): raise SystemExit("Cluster '%s' not defined in %s" % (cluster, self.config_file)) try: return bool(self.config.get(cluster, 'whisper_lock_writes')) except NoOptionError: return False
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end block if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier attribute identifier identifier try_statement block return_statement call identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end except_clause identifier block return_statement false
Lock whisper files during carbon-sync.
def on_batch_end(self, batch_info): if self.settings.stream_lr: iteration_idx = ( float(batch_info.epoch_number) + float(batch_info.batch_number) / batch_info.batches_per_epoch ) lr = batch_info.optimizer.param_groups[-1]['lr'] metrics_df = pd.DataFrame([lr], index=[iteration_idx], columns=['lr']) visdom_append_metrics( self.vis, metrics_df, first_epoch=(batch_info.epoch_number == 1) and (batch_info.batch_number == 0) )
module function_definition identifier parameters identifier identifier block if_statement attribute attribute identifier identifier identifier block expression_statement assignment identifier parenthesized_expression binary_operator call identifier argument_list attribute identifier identifier binary_operator call identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement assignment identifier subscript subscript attribute attribute identifier identifier identifier unary_operator integer string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list list identifier keyword_argument identifier list identifier keyword_argument identifier list string string_start string_content string_end expression_statement call identifier argument_list attribute identifier identifier identifier keyword_argument identifier boolean_operator parenthesized_expression comparison_operator attribute identifier identifier integer parenthesized_expression comparison_operator attribute identifier identifier integer
Stream LR to visdom
def _render_object(self, obj, *context, **kwargs): loader = self._make_loader() if isinstance(obj, TemplateSpec): loader = SpecLoader(loader) template = loader.load(obj) else: template = loader.load_object(obj) context = [obj] + list(context) return self._render_string(template, *context, **kwargs)
module function_definition identifier parameters identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier binary_operator list identifier call identifier argument_list identifier return_statement call attribute identifier identifier argument_list identifier list_splat identifier dictionary_splat identifier
Render the template associated with the given object.
def camel_case(self, snake_case): components = snake_case.split('_') return components[0] + "".join(x.title() for x in components[1:])
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end return_statement binary_operator subscript identifier integer call attribute string string_start string_end identifier generator_expression call attribute identifier identifier argument_list for_in_clause identifier subscript identifier slice integer
Convert snake case to camel case
def uuid(anon, obj, field, val): return anon.faker.uuid(field=field)
module function_definition identifier parameters identifier identifier identifier identifier block return_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier
Returns a random uuid string
def matmul_adjoint_x(dz, x, y, transpose_a, transpose_b): if not transpose_a and not transpose_b: return tf.matmul(dz, y, transpose_b=True) elif not transpose_a and transpose_b: return tf.matmul(dz, y) elif transpose_a and not transpose_b: return tf.matmul(y, dz, transpose_b=True) else: return tf.matmul(y, dz, transpose_a=True, transpose_b=True)
module function_definition identifier parameters identifier identifier identifier identifier identifier block if_statement boolean_operator not_operator identifier not_operator identifier block return_statement call attribute identifier identifier argument_list identifier identifier keyword_argument identifier true elif_clause boolean_operator not_operator identifier identifier block return_statement call attribute identifier identifier argument_list identifier identifier elif_clause boolean_operator identifier not_operator identifier block return_statement call attribute identifier identifier argument_list identifier identifier keyword_argument identifier true else_clause block return_statement call attribute identifier identifier argument_list identifier identifier keyword_argument identifier true keyword_argument identifier true
Implementation of dtfmatmul wrt x, separate for readability.
def allFeatures(self): for dataset in self.getDatasets(): for featureSet in dataset.getFeatureSets(): for feature in featureSet.getFeatures(): yield feature
module function_definition identifier parameters identifier block for_statement identifier call attribute identifier identifier argument_list block for_statement identifier call attribute identifier identifier argument_list block for_statement identifier call attribute identifier identifier argument_list block expression_statement yield identifier
Return an iterator over all features in the data repo
def start(): setupdir = dirname(dirname(__file__)) curdir = os.getcwd() if len(sys.argv) > 1: configfile = sys.argv[1] elif exists(join(setupdir, "setup.py")): configfile = join(setupdir, "dev.cfg") elif exists(join(curdir, "prod.cfg")): configfile = join(curdir, "prod.cfg") else: try: configfile = pkg_resources.resource_filename( pkg_resources.Requirement.parse("tgpisa"), "config/default.cfg") except pkg_resources.DistributionNotFound: raise ConfigurationError("Could not find default configuration.") turbogears.update_config(configfile=configfile, modulename="tgpisa.config") from tgpisa.controllers import Root turbogears.start_server(Root())
module function_definition identifier parameters block expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator call identifier argument_list attribute identifier identifier integer block expression_statement assignment identifier subscript attribute identifier identifier integer elif_clause call identifier argument_list call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end elif_clause call identifier argument_list call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end else_clause block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end except_clause attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end import_from_statement dotted_name identifier identifier dotted_name identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list
Start the CherryPy application server.
async def fetchone(self) -> Optional[sqlite3.Row]: return await self._execute(self._cursor.fetchone)
module function_definition identifier parameters identifier type generic_type identifier type_parameter type attribute identifier identifier block return_statement await call attribute identifier identifier argument_list attribute attribute identifier identifier identifier
Fetch a single row.
def prev_cursor_location(self): self._verify_entrypoint_selected() self.current_trace_frame_index = max(self.current_trace_frame_index - 1, 0) self.trace()
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier call identifier argument_list binary_operator attribute identifier identifier integer integer expression_statement call attribute identifier identifier argument_list
Move cursor to the previous trace frame.
def _read(self): while self._rxactive: try: rv = self._ep_in.read(self._ep_in.wMaxPacketSize) if self._isFTDI: status = rv[:2] if status[0] != 1 or status[1] != 0x60: log.info( "USB Status: 0x{0:02X} 0x{1:02X}".format( *status)) rv = rv[2:] for rvi in rv: self._rxqueue.put(rvi) except usb.USBError as e: log.warn("USB Error on _read {}".format(e)) return time.sleep(self._rxinterval)
module function_definition identifier parameters identifier block while_statement attribute identifier identifier block try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier if_statement attribute identifier identifier block expression_statement assignment identifier subscript identifier slice integer if_statement boolean_operator comparison_operator subscript identifier integer integer comparison_operator subscript identifier integer integer block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list list_splat identifier expression_statement assignment identifier subscript identifier slice integer for_statement identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier except_clause as_pattern attribute identifier identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier return_statement expression_statement call attribute identifier identifier argument_list attribute identifier identifier
check ep for data, add it to queue and sleep for interval
def create_view(self, request): try: if request.user.is_authenticated(): return redirect("organization_add") except TypeError: if request.user.is_authenticated: return redirect("organization_add") form = org_registration_form(self.org_model)(request.POST or None) if form.is_valid(): try: user = self.user_model.objects.get(email=form.cleaned_data["email"]) except self.user_model.DoesNotExist: user = self.user_model.objects.create( username=self.get_username(), email=form.cleaned_data["email"], password=self.user_model.objects.make_random_password(), ) user.is_active = False user.save() else: return redirect("organization_add") organization = create_organization( user, form.cleaned_data["name"], form.cleaned_data["slug"], is_active=False, ) return render( request, self.activation_success_template, {"user": user, "organization": organization}, ) return render(request, self.registration_form_template, {"form": form})
module function_definition identifier parameters identifier identifier block try_statement block if_statement call attribute attribute identifier identifier identifier argument_list block return_statement call identifier argument_list string string_start string_content string_end except_clause identifier block if_statement attribute attribute identifier identifier identifier block return_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call call identifier argument_list attribute identifier identifier argument_list boolean_operator attribute identifier identifier none if_statement call attribute identifier identifier argument_list block try_statement block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list keyword_argument identifier subscript attribute identifier identifier string string_start string_content string_end except_clause attribute attribute identifier identifier identifier block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list keyword_argument identifier subscript attribute identifier identifier string string_start string_content string_end keyword_argument identifier call attribute attribute attribute identifier identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier false expression_statement call attribute identifier identifier argument_list else_clause block return_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier subscript attribute identifier identifier string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end keyword_argument identifier false return_statement call identifier argument_list identifier attribute identifier identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier return_statement call identifier argument_list identifier attribute identifier identifier dictionary pair string string_start string_content string_end identifier
Initiates the organization and user account creation process
def execute(self): self.start_stemming_process() if self.dictionary.contains(self.current_word): self.result = self.current_word else: self.result = self.original_word
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list if_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier block expression_statement assignment attribute identifier identifier attribute identifier identifier else_clause block expression_statement assignment attribute identifier identifier attribute identifier identifier
Execute stemming process; the result can be retrieved with result
async def stop(self): self._logger.info("Stopping all servers") for server in self.servers: await server.stop() self._logger.info("Stopping all device adapters") await self.device_manager.stop()
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end for_statement identifier attribute identifier identifier block expression_statement await call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement await call attribute attribute identifier identifier identifier argument_list
Stop the gateway manager and synchronously wait for it to stop.
def restore(self, volume_id, **kwargs): self.required('create', kwargs, ['backup', 'size']) volume_id = volume_id or str(uuid.uuid4()) kwargs['volume_type_name'] = kwargs['volume_type_name'] or 'vtype' kwargs['size'] = kwargs['size'] or 1 return self.http_put('/volumes/%s' % volume_id, params=self.unused(kwargs))
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier boolean_operator identifier call identifier argument_list call attribute identifier identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end boolean_operator subscript identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end boolean_operator subscript identifier string string_start string_content string_end integer return_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier keyword_argument identifier call attribute identifier identifier argument_list identifier
restore a volume from a backup
def describe(self): stats = {} stats['samples'] = self.shape[0] stats['nulls'] = self[np.isnan(self)].shape[0] stats['mean'] = float(np.nanmean(self.real)) stats['min'] = float(np.nanmin(self.real)) stats['max'] = float(np.nanmax(self.real)) return stats
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary expression_statement assignment subscript identifier string string_start string_content string_end subscript attribute identifier identifier integer expression_statement assignment subscript identifier string string_start string_content string_end subscript attribute subscript identifier call attribute identifier identifier argument_list identifier identifier integer expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier return_statement identifier
Return basic statistics about the curve.
def delete(self, commit=True): db.session.delete(self) return commit and db.session.commit()
module function_definition identifier parameters identifier default_parameter identifier true block expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement boolean_operator identifier call attribute attribute identifier identifier identifier argument_list
Delete model from database
def login(self, user, passwd): resp = self.post('token', json={'username': user, 'password': passwd}) self._token = resp.json()['response']['token']
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier expression_statement assignment attribute identifier identifier subscript subscript call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end
Logs the user into SecurityCenter and stores the needed token and cookies.
def visit_Import(self, node): line = self._code_lines[node.lineno - 1] module_name = line.split("import")[0].strip() for name in node.names: imported_name = name.name if name.asname: imported_name = name.asname + "::" + imported_name self.imported_namespaces[imported_name] = module_name
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier binary_operator attribute identifier identifier integer expression_statement assignment identifier call attribute subscript call attribute identifier identifier argument_list string string_start string_content string_end integer identifier argument_list for_statement identifier attribute identifier identifier block expression_statement assignment identifier attribute identifier identifier if_statement attribute identifier identifier block expression_statement assignment identifier binary_operator binary_operator attribute identifier identifier string string_start string_content string_end identifier expression_statement assignment subscript attribute identifier identifier identifier identifier
Visit an import node.
def write_index(self): self.fileobj.seek(self.last_offset) index = index_header.build(dict(entries=self.entries)) self.fileobj.write(index) self.filesize = self.fileobj.tell()
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list keyword_argument identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list
Write the index of all our files to the MAR file.
def close(self): windll.kernel32.CloseHandle(self.conout_pipe) windll.kernel32.CloseHandle(self.conin_pipe)
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier
Close all communication process streams.
def run_fsm(self, name, command, events, transitions, timeout, max_transitions=20): self.ctrl.send_command(command) return FSM(name, self, events, transitions, timeout=timeout, max_transitions=max_transitions).run()
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier default_parameter identifier integer block expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement call attribute call identifier argument_list identifier identifier identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier identifier argument_list
Wrap the FSM code.
def _persist(self) -> None: if self._store: self._store.save(self._key, self._snapshot)
module function_definition identifier parameters identifier type none block if_statement attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier attribute identifier identifier
Persists the current data group
def motors_armed(self): if not 'HEARTBEAT' in self.messages: return False m = self.messages['HEARTBEAT'] return (m.base_mode & mavlink.MAV_MODE_FLAG_SAFETY_ARMED) != 0
module function_definition identifier parameters identifier block if_statement not_operator comparison_operator string string_start string_content string_end attribute identifier identifier block return_statement false expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end return_statement comparison_operator parenthesized_expression binary_operator attribute identifier identifier attribute identifier identifier integer
return true if motors armed
def block(self): if (self.is_actinoid or self.is_lanthanoid) and self.Z not in [71, 103]: return "f" elif self.is_actinoid or self.is_lanthanoid: return "d" elif self.group in [1, 2]: return "s" elif self.group in range(13, 19): return "p" elif self.group in range(3, 13): return "d" raise ValueError("unable to determine block")
module function_definition identifier parameters identifier block if_statement boolean_operator parenthesized_expression boolean_operator attribute identifier identifier attribute identifier identifier comparison_operator attribute identifier identifier list integer integer block return_statement string string_start string_content string_end elif_clause boolean_operator attribute identifier identifier attribute identifier identifier block return_statement string string_start string_content string_end elif_clause comparison_operator attribute identifier identifier list integer integer block return_statement string string_start string_content string_end elif_clause comparison_operator attribute identifier identifier call identifier argument_list integer integer block return_statement string string_start string_content string_end elif_clause comparison_operator attribute identifier identifier call identifier argument_list integer integer block return_statement string string_start string_content string_end raise_statement call identifier argument_list string string_start string_content string_end
Return the block character "s,p,d,f"
def delete(self, file_path): if os.sep in file_path: directory, file_name = file_path.rsplit(os.sep, 1) self.chdir(directory) return self.session.delete(file_name) else: return self.session.delete(file_path)
module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list attribute identifier identifier integer expression_statement call attribute identifier identifier argument_list identifier return_statement call attribute attribute identifier identifier identifier argument_list identifier else_clause block return_statement call attribute attribute identifier identifier identifier argument_list identifier
Remove the file named filename from the server.
def priorfactors(self): priorfactors = {} for pop in self.poplist: for f in pop.priorfactors: if f in priorfactors: if pop.priorfactors[f] != priorfactors[f]: raise ValueError('prior factor %s is inconsistent!' % f) else: priorfactors[f] = pop.priorfactors[f] return priorfactors
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary for_statement identifier attribute identifier identifier block for_statement identifier attribute identifier identifier block if_statement comparison_operator identifier identifier block if_statement comparison_operator subscript attribute identifier identifier identifier subscript 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 identifier identifier subscript attribute identifier identifier identifier return_statement identifier
Combinartion of priorfactors from all populations
def publish_event(self, channel, event, message): assert self.protocol is not None, "Protocol required" msg = {'event': event, 'channel': channel} if message: msg['data'] = message return self.publish(channel, msg)
module function_definition identifier parameters identifier identifier identifier identifier block assert_statement comparison_operator attribute identifier identifier none string string_start string_content string_end expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier if_statement identifier block expression_statement assignment subscript identifier string string_start string_content string_end identifier return_statement call attribute identifier identifier argument_list identifier identifier
Publish a new event ``message`` to a ``channel``.
def _init_training(self): if self.check: self.backprop = CheckedBackprop(self.network, self.problem.cost) else: self.backprop = BatchBackprop(self.network, self.problem.cost) self.momentum = Momentum() self.decent = GradientDecent() self.decay = WeightDecay() self.tying = WeightTying(*self.problem.weight_tying) self.weights = self.tying(self.weights)
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier attribute attribute identifier identifier identifier else_clause block expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier attribute attribute identifier identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list expression_statement assignment attribute identifier identifier call identifier argument_list expression_statement assignment attribute identifier identifier call identifier argument_list expression_statement assignment attribute identifier identifier call identifier argument_list list_splat attribute attribute identifier identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier
Classes needed during training.
def calc_max_bits(self, signed, values): b = 0 vmax = -10000000 for val in values: if signed: b = b | val if val >= 0 else b | ~val << 1 vmax = val if vmax < val else vmax else: b |= val; bits = 0 if b > 0: bits = len(self.bin(b)) - 2 if signed and vmax > 0 and len(self.bin(vmax)) - 2 >= bits: bits += 1 return bits
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier integer expression_statement assignment identifier unary_operator integer for_statement identifier identifier block if_statement identifier block expression_statement assignment identifier conditional_expression binary_operator identifier identifier comparison_operator identifier integer binary_operator identifier binary_operator unary_operator identifier integer expression_statement assignment identifier conditional_expression identifier comparison_operator identifier identifier identifier else_clause block expression_statement augmented_assignment identifier identifier expression_statement assignment identifier integer if_statement comparison_operator identifier integer block expression_statement assignment identifier binary_operator call identifier argument_list call attribute identifier identifier argument_list identifier integer if_statement boolean_operator boolean_operator identifier comparison_operator identifier integer comparison_operator binary_operator call identifier argument_list call attribute identifier identifier argument_list identifier integer identifier block expression_statement augmented_assignment identifier integer return_statement identifier
Calculates the maximim needed bits to represent a value
def PrintSets(self): sets=self._getphotosets() for setname in sets: print("%s [%d]"%(setname,sets[setname]['number_photos']))
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list for_statement identifier identifier block expression_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier subscript subscript identifier identifier string string_start string_content string_end
Prints set name and number of photos in set
def extract_attributes(cls, fields, resource): data = OrderedDict() for field_name, field in six.iteritems(fields): if field_name == 'id': continue if fields[field_name].write_only: continue if isinstance( field, (relations.RelatedField, relations.ManyRelatedField, BaseSerializer) ): continue try: resource[field_name] except KeyError: if fields[field_name].read_only: continue data.update({ field_name: resource.get(field_name) }) return utils._format_object(data)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call identifier argument_list for_statement pattern_list identifier identifier call attribute identifier identifier argument_list identifier block if_statement comparison_operator identifier string string_start string_content string_end block continue_statement if_statement attribute subscript identifier identifier identifier block continue_statement if_statement call identifier argument_list identifier tuple attribute identifier identifier attribute identifier identifier identifier block continue_statement try_statement block expression_statement subscript identifier identifier except_clause identifier block if_statement attribute subscript identifier identifier identifier block continue_statement expression_statement call attribute identifier identifier argument_list dictionary pair identifier call attribute identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list identifier
Builds the `attributes` object of the JSON API resource object.
def _check_gzipped_input(in_file, data): grabix = config_utils.get_program("grabix", data["config"]) is_bgzip = subprocess.check_output([grabix, "check", in_file]) if is_bgzip.strip() == "yes": return False, False else: return True, True
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list list identifier string string_start string_content string_end identifier if_statement comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end block return_statement expression_list false false else_clause block return_statement expression_list true true
Determine if a gzipped input file is blocked gzip or standard.
def _ScheduleVariableHunt(hunt_obj): if hunt_obj.client_rate != 0: raise VariableHuntCanNotHaveClientRateError(hunt_obj.hunt_id, hunt_obj.client_rate) seen_clients = set() for flow_group in hunt_obj.args.variable.flow_groups: for client_id in flow_group.client_ids: if client_id in seen_clients: raise CanStartAtMostOneFlowPerClientError(hunt_obj.hunt_id, client_id) seen_clients.add(client_id) now = rdfvalue.RDFDatetime.Now() for flow_group in hunt_obj.args.variable.flow_groups: flow_cls = registry.FlowRegistry.FlowClassByName(flow_group.flow_name) flow_args = flow_group.flow_args if flow_group.HasField( "flow_args") else None for client_id in flow_group.client_ids: flow.StartFlow( client_id=client_id, creator=hunt_obj.creator, cpu_limit=hunt_obj.per_client_cpu_limit, network_bytes_limit=hunt_obj.per_client_network_bytes_limit, flow_cls=flow_cls, flow_args=flow_args, start_at=now, parent_hunt_id=hunt_obj.hunt_id)
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier integer block raise_statement call identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list for_statement identifier attribute attribute attribute identifier identifier identifier identifier block for_statement identifier attribute identifier identifier block if_statement comparison_operator identifier identifier block raise_statement call identifier argument_list attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list for_statement identifier attribute attribute attribute identifier identifier identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier conditional_expression attribute identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end none for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier
Schedules flows for a variable hunt.
def quadkey_to_tile(quadkey): tile_x, tile_y = (0, 0) level = len(quadkey) for i in xrange(level): bit = level - i mask = 1 << (bit - 1) if quadkey[level - bit] == '1': tile_x |= mask if quadkey[level - bit] == '2': tile_y |= mask if quadkey[level - bit] == '3': tile_x |= mask tile_y |= mask return [(tile_x, tile_y), level]
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier tuple integer integer expression_statement assignment identifier call identifier argument_list identifier for_statement identifier call identifier argument_list identifier block expression_statement assignment identifier binary_operator identifier identifier expression_statement assignment identifier binary_operator integer parenthesized_expression binary_operator identifier integer if_statement comparison_operator subscript identifier binary_operator identifier identifier string string_start string_content string_end block expression_statement augmented_assignment identifier identifier if_statement comparison_operator subscript identifier binary_operator identifier identifier string string_start string_content string_end block expression_statement augmented_assignment identifier identifier if_statement comparison_operator subscript identifier binary_operator identifier identifier string string_start string_content string_end block expression_statement augmented_assignment identifier identifier expression_statement augmented_assignment identifier identifier return_statement list tuple identifier identifier identifier
Transform quadkey to tile coordinates
def pip(filename): requirements = [] for line in open(join(ROOT, 'requirements', filename)): line = line.strip() if not line or '://' in line: continue match = RE_REQUIREMENT.match(line) if match: requirements.extend(pip(match.group('filename'))) else: requirements.append(line) return requirements
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier call identifier argument_list call identifier argument_list identifier string string_start string_content string_end identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement boolean_operator not_operator identifier comparison_operator string string_start string_content string_end identifier block continue_statement expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end else_clause block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Parse pip reqs file and transform it to setuptools requirements.
def populate_iteration(self, iteration): cur_idx = iteration.cur_idx genotypes = self.genotype_file.next().split() iteration.chr, iteration.rsid, junk, iteration.pos = genotypes[0:4] iteration.chr = int(iteration.chr) iteration.pos = int(iteration.pos) if DataParser.boundary.TestBoundary(iteration.chr, iteration.pos, iteration.rsid): try: [iteration.genotype_data, iteration.major_allele, iteration.minor_allele, iteration.hetero_count, iteration.maj_allele_count, iteration.min_allele_count, iteration.missing_allele_count, iteration.allele_count2] = self.process_genotypes(genotypes) return iteration.maf >= DataParser.min_maf and iteration.maf <= DataParser.max_maf except TooFewAlleles: print "\n\n\nSkipping %s:%s %s %s" % (iteration.chr, iteration.pos, iteration.rsid, cur_idx) return False
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list expression_statement assignment pattern_list attribute identifier identifier attribute identifier identifier identifier attribute identifier identifier subscript identifier slice integer integer expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier if_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier block try_statement block expression_statement assignment list_pattern attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier call attribute identifier identifier argument_list identifier return_statement boolean_operator comparison_operator attribute identifier identifier attribute identifier identifier comparison_operator attribute identifier identifier attribute identifier identifier except_clause identifier block print_statement binary_operator string string_start string_content escape_sequence escape_sequence escape_sequence string_end tuple attribute identifier identifier attribute identifier identifier attribute identifier identifier identifier return_statement false
Pour the current data into the iteration object
def read_numbers(numbers): if isiterable(numbers): for number in numbers: yield float(str(number).strip()) else: with open(numbers) as fh: for number in fh: yield float(number.strip())
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier block for_statement identifier identifier block expression_statement yield call identifier argument_list call attribute call identifier argument_list identifier identifier argument_list else_clause block with_statement with_clause with_item as_pattern call identifier argument_list identifier as_pattern_target identifier block for_statement identifier identifier block expression_statement yield call identifier argument_list call attribute identifier identifier argument_list
Read the input data in the most optimal way
def collides_axisaligned_rect(self, other): self_shifted = RotoOriginRect(self.width, self.height, -self.angle) s_a = self.sin_a() c_a = self.cos_a() center_x = self.x + self.width / 2.0 * c_a - self.height / 2.0 * s_a center_y = self.y - self.height / 2.0 * c_a - self.width / 2.0 * s_a other_shifted = Rect(other.x - center_x, other.y - center_y, other.width, other.height) return self_shifted.collides(other_shifted)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier attribute identifier identifier unary_operator attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier binary_operator binary_operator attribute identifier identifier binary_operator binary_operator attribute identifier identifier float identifier binary_operator binary_operator attribute identifier identifier float identifier expression_statement assignment identifier binary_operator binary_operator attribute identifier identifier binary_operator binary_operator attribute identifier identifier float identifier binary_operator binary_operator attribute identifier identifier float identifier expression_statement assignment identifier call identifier argument_list binary_operator attribute identifier identifier identifier binary_operator attribute identifier identifier identifier attribute identifier identifier attribute identifier identifier return_statement call attribute identifier identifier argument_list identifier
Returns collision with axis aligned other rect
def getCitiesDrawingXML(points): xml = "" for p in points: x = str(p.x) z = str(p.y) xml += '<DrawBlock x="' + x + '" y="7" z="' + z + '" type="beacon"/>' xml += '<DrawItem x="' + x + '" y="10" z="' + z + '" type="ender_pearl"/>' return xml
module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_end for_statement identifier identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement augmented_assignment identifier binary_operator binary_operator binary_operator binary_operator string string_start string_content string_end identifier string string_start string_content string_end identifier string string_start string_content string_end expression_statement augmented_assignment identifier binary_operator binary_operator binary_operator binary_operator string string_start string_content string_end identifier string string_start string_content string_end identifier string string_start string_content string_end return_statement identifier
Build an XML string that contains a square for each city
def dt_comp(self, sampled_topics): samples = sampled_topics.shape[0] dt = np.zeros((self.D, self.K, samples)) for s in range(samples): dt[:, :, s] = \ samplers_lda.dt_comp(self.docid, sampled_topics[s, :], self.N, self.K, self.D, self.alpha) return dt
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list tuple attribute identifier identifier attribute identifier identifier identifier for_statement identifier call identifier argument_list identifier block expression_statement assignment subscript identifier slice slice identifier line_continuation call attribute identifier identifier argument_list attribute identifier identifier subscript identifier identifier slice attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier return_statement identifier
Compute document-topic matrix from sampled_topics.
def include_file(self, uri, **kwargs): _include_file(self.context, uri, self._templateuri, **kwargs)
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block expression_statement call identifier argument_list attribute identifier identifier identifier attribute identifier identifier dictionary_splat identifier
Include a file at the given ``uri``.
def gauss_box_model_deriv(x, amplitude=1.0, mean=0.0, stddev=1.0, hpix=0.5): z = (x - mean) / stddev z2 = z + hpix / stddev z1 = z - hpix / stddev da = norm.cdf(z2) - norm.cdf(z1) fp2 = norm_pdf_t(z2) fp1 = norm_pdf_t(z1) dl = -amplitude / stddev * (fp2 - fp1) ds = -amplitude / stddev * (fp2 * z2 - fp1 * z1) dd = amplitude / stddev * (fp2 + fp1) return da, dl, ds, dd
module function_definition identifier parameters identifier default_parameter identifier float default_parameter identifier float default_parameter identifier float default_parameter identifier float block expression_statement assignment identifier binary_operator parenthesized_expression binary_operator identifier identifier identifier expression_statement assignment identifier binary_operator identifier binary_operator identifier identifier expression_statement assignment identifier binary_operator identifier binary_operator identifier identifier expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier binary_operator binary_operator unary_operator identifier identifier parenthesized_expression binary_operator identifier identifier expression_statement assignment identifier binary_operator binary_operator unary_operator identifier identifier parenthesized_expression binary_operator binary_operator identifier identifier binary_operator identifier identifier expression_statement assignment identifier binary_operator binary_operator identifier identifier parenthesized_expression binary_operator identifier identifier return_statement expression_list identifier identifier identifier identifier
Derivative of the integral of a Gaussian profile.
def goto_position(self, position, duration, control=None, wait=False): if control is None: control = self.goto_behavior if control == 'minjerk': goto_min_jerk = GotoMinJerk(self, position, duration) goto_min_jerk.start() if wait: goto_min_jerk.wait_to_stop() elif control == 'dummy': dp = abs(self.present_position - position) speed = (dp / float(duration)) if duration > 0 else numpy.inf self.moving_speed = speed self.goal_position = position if wait: time.sleep(duration)
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none default_parameter identifier false block if_statement comparison_operator identifier none block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list identifier identifier identifier expression_statement call attribute identifier identifier argument_list if_statement identifier block expression_statement call attribute identifier identifier argument_list elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list binary_operator attribute identifier identifier identifier expression_statement assignment identifier conditional_expression parenthesized_expression binary_operator identifier call identifier argument_list identifier comparison_operator identifier integer attribute identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier
Automatically sets the goal position and the moving speed to reach the desired position within the duration.
def run(self): self.signals() with self.listener(): for job in self.jobs(): if not job: self.jid = None self.title('Sleeping for %fs' % self.interval) time.sleep(self.interval) else: self.jid = job.jid self.title('Working on %s (%s)' % (job.jid, job.klass_name)) with Worker.sandbox(self.sandbox): job.sandbox = self.sandbox job.process() if self.shutdown: break
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list with_statement with_clause with_item call attribute identifier identifier argument_list block for_statement identifier call attribute identifier identifier argument_list block if_statement not_operator identifier block expression_statement assignment attribute identifier identifier none expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier else_clause block expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple attribute identifier identifier attribute identifier identifier with_statement with_clause with_item call attribute identifier identifier argument_list attribute identifier identifier block expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list if_statement attribute identifier identifier block break_statement
Run jobs, popping one after another
def setup_callbacks(self): if PYGIT2_VERSION >= _LooseVersion('0.23.2'): self.remotecallbacks = pygit2.RemoteCallbacks( credentials=self.credentials) if not self.ssl_verify: self.remotecallbacks.certificate_check = \ lambda *args, **kwargs: True else: self.remotecallbacks = None if not self.ssl_verify: warnings.warn( 'pygit2 does not support disabling the SSL certificate ' 'check in versions prior to 0.23.2 (installed: {0}). ' 'Fetches for self-signed certificates will fail.'.format( PYGIT2_VERSION ) )
module function_definition identifier parameters identifier block if_statement comparison_operator identifier call identifier argument_list string string_start string_content string_end block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier if_statement not_operator attribute identifier identifier block expression_statement assignment attribute attribute identifier identifier identifier line_continuation lambda lambda_parameters list_splat_pattern identifier dictionary_splat_pattern identifier true else_clause block expression_statement assignment attribute identifier identifier none if_statement not_operator attribute identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute concatenated_string 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
Assign attributes for pygit2 callbacks
def compress_pdf(pdf_fpath, output_fname=None): import utool as ut ut.assertpath(pdf_fpath) suffix = '_' + ut.get_datestamp(False) + '_compressed' print('pdf_fpath = %r' % (pdf_fpath,)) output_pdf_fpath = ut.augpath(pdf_fpath, suffix, newfname=output_fname) print('output_pdf_fpath = %r' % (output_pdf_fpath,)) gs_exe = find_ghostscript_exe() cmd_list = ( gs_exe, '-sDEVICE=pdfwrite', '-dCompatibilityLevel=1.4', '-dNOPAUSE', '-dQUIET', '-dBATCH', '-sOutputFile=' + output_pdf_fpath, pdf_fpath ) ut.cmd(*cmd_list) return output_pdf_fpath
module function_definition identifier parameters identifier default_parameter identifier none block import_statement aliased_import dotted_name identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier binary_operator binary_operator string string_start string_content string_end call attribute identifier identifier argument_list false string string_start string_content string_end expression_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier keyword_argument identifier identifier expression_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier tuple identifier 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 binary_operator string string_start string_content string_end identifier identifier expression_statement call attribute identifier identifier argument_list list_splat identifier return_statement identifier
uses ghostscript to write a pdf
def list(self, limit=None, offset=None): uri = "/%s%s" % (self.uri_base, self._get_pagination_qs(limit, offset)) return self._list(uri)
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple attribute identifier identifier call attribute identifier identifier argument_list identifier identifier return_statement call attribute identifier identifier argument_list identifier
Gets a list of all domains, or optionally a page of domains.
def imported_classifiers_package(p: ecore.EPackage): classes = {c for c in p.eClassifiers if isinstance(c, ecore.EClass)} references = itertools.chain(*(c.eAllReferences() for c in classes)) references_types = (r.eType for r in references) imported = {c for c in references_types if getattr(c, 'ePackage', p) is not p} imported_dict = {} for classifier in imported: imported_dict.setdefault(classifier.ePackage, set()).add(classifier) return imported_dict
module function_definition identifier parameters typed_parameter identifier type attribute identifier identifier block expression_statement assignment identifier set_comprehension identifier for_in_clause identifier attribute identifier identifier if_clause call identifier argument_list identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list list_splat generator_expression call attribute identifier identifier argument_list for_in_clause identifier identifier expression_statement assignment identifier generator_expression attribute identifier identifier for_in_clause identifier identifier expression_statement assignment identifier set_comprehension identifier for_in_clause identifier identifier if_clause comparison_operator call identifier argument_list identifier string string_start string_content string_end identifier identifier expression_statement assignment identifier dictionary for_statement identifier identifier block expression_statement call attribute call attribute identifier identifier argument_list attribute identifier identifier call identifier argument_list identifier argument_list identifier return_statement identifier
Determines which classifiers have to be imported into given package.
def Options(**kwargs): construct = GPDOptions names = construct._fields d = {} for name in names: d[name] = None for k,v in kwargs.iteritems(): if k in names: d[k] = v else: raise ValueError('Error '+k+' is not a property of these options') return construct(**d)
module function_definition identifier parameters dictionary_splat_pattern identifier block expression_statement assignment identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier dictionary for_statement identifier identifier block expression_statement assignment subscript identifier identifier none for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement comparison_operator identifier identifier block expression_statement assignment subscript identifier identifier identifier else_clause block raise_statement call identifier argument_list binary_operator binary_operator string string_start string_content string_end identifier string string_start string_content string_end return_statement call identifier argument_list dictionary_splat identifier
A method for declaring options for the class
def handle(self): self.output = PyStratumStyle(self.input, self.output) config_file = self.input.get_argument('config_file') self.run_command(config_file)
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier
Executes constants command when PyStratumCommand is activated.
def add_answer_at_time(self, record, now): if record is not None: if now == 0 or not record.is_expired(now): self.answers.append((record, now)) if record.rrsig is not None: self.answers.append((record.rrsig, now))
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator identifier none block if_statement boolean_operator comparison_operator identifier integer not_operator call attribute identifier identifier argument_list identifier block expression_statement call attribute attribute identifier identifier identifier argument_list tuple identifier identifier if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list tuple attribute identifier identifier identifier
Adds an answer if if does not expire by a certain time
def remove_network_profile(self, obj, params): network_id = -1 profiles = self.network_profiles(obj) for profile in profiles: if profile == params: network_id = profile.id if network_id != -1: self._send_cmd_to_wpas(obj['name'], 'REMOVE_NETWORK {}'.format(network_id))
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier unary_operator integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier for_statement identifier identifier block if_statement comparison_operator identifier identifier block expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier unary_operator integer block expression_statement call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list identifier
Remove the specified AP profiles
def _check_current_value(gnome_kwargs, value): current_value = __salt__['gnome.get'](**gnome_kwargs) return six.text_type(current_value) == six.text_type(value)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call subscript identifier string string_start string_content string_end argument_list dictionary_splat identifier return_statement comparison_operator call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier
Check the current value with the passed value
def all_substrings(s): join = ''.join for i in range(1, len(s) + 1): for sub in window(s, i): yield join(sub)
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute string string_start string_end identifier for_statement identifier call identifier argument_list integer binary_operator call identifier argument_list identifier integer block for_statement identifier call identifier argument_list identifier identifier block expression_statement yield call identifier argument_list identifier
yields all substrings of a string
def data_filler_user_agent(self, number_of_rows, pipe): try: for i in range(number_of_rows): pipe.hmset('user_agent:%s' % i, { 'id': rnd_id_generator(self), 'ip': self.faker.ipv4(), 'countrycode': self.faker.country_code(), 'useragent': self.faker.user_agent() }) pipe.execute() logger.warning('user_agent Commits are successful after write job!', extra=d) except Exception as e: logger.error(e, extra=d)
module function_definition identifier parameters identifier identifier identifier block try_statement block for_statement identifier call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier dictionary pair string string_start string_content string_end call identifier argument_list identifier pair string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list pair string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list pair string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier
creates keys with user agent data
def _parse_band(cls, kw): m = re.search('([a-zA-Z0-9]+)(_\d+)?', kw) if m: if m.group(1) in cls._not_a_band: return None else: return m.group(1)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement identifier block if_statement comparison_operator call attribute identifier identifier argument_list integer attribute identifier identifier block return_statement none else_clause block return_statement call attribute identifier identifier argument_list integer
Returns photometric band from inifile keyword
def logon(): content = {} payload = "<aaaLogin inName='{0}' inPassword='{1}'></aaaLogin>".format(DETAILS['username'], DETAILS['password']) r = __utils__['http.query'](DETAILS['url'], data=payload, method='POST', decode_type='plain', decode=True, verify_ssl=False, raise_error=False, status=True, headers=DETAILS['headers']) _validate_response_code(r['status']) answer = re.findall(r'(<[\s\S.]*>)', r['text'])[0] items = ET.fromstring(answer) for item in items.attrib: content[item] = items.attrib[item] if 'outCookie' not in content: raise salt.exceptions.CommandExecutionError("Unable to log into proxy device.") return content['outCookie']
module function_definition identifier parameters block expression_statement assignment identifier dictionary expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement assignment identifier call subscript identifier string string_start string_content string_end argument_list subscript identifier string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier true keyword_argument identifier false keyword_argument identifier false keyword_argument identifier true keyword_argument identifier subscript identifier string string_start string_content string_end expression_statement call identifier argument_list subscript identifier string string_start string_content string_end expression_statement assignment identifier subscript call attribute identifier identifier argument_list string string_start string_content string_end subscript identifier string string_start string_content string_end integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier for_statement identifier attribute identifier identifier block expression_statement assignment subscript identifier identifier subscript attribute identifier identifier identifier if_statement comparison_operator string string_start string_content string_end identifier block raise_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end return_statement subscript identifier string string_start string_content string_end
Logs into the cimc device and returns the session cookie.
def _POUpdateBuilderWrapper(env, target=None, source=_null, **kw): if source is _null: if 'POTDOMAIN' in kw: domain = kw['POTDOMAIN'] elif 'POTDOMAIN' in env and env['POTDOMAIN']: domain = env['POTDOMAIN'] else: domain = 'messages' source = [ domain ] return env._POUpdateBuilder(target, source, **kw)
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier identifier dictionary_splat_pattern identifier block if_statement comparison_operator identifier identifier block if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end elif_clause boolean_operator comparison_operator string string_start string_content string_end identifier subscript identifier string string_start string_content string_end block expression_statement assignment identifier subscript identifier string string_start string_content string_end else_clause block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier list identifier return_statement call attribute identifier identifier argument_list identifier identifier dictionary_splat identifier
Wrapper for `POUpdate` builder - make user's life easier
def render_desc(desc): desc = desc + '.' desc_lines = split_len(desc, 54) if len(desc_lines) > 1: join_str = "'\n%s'" % (' '*21) lines_str = join_str.join(desc_lines) out = "('%s')" % lines_str else: out = "'%s'" % desc_lines[0] return out
module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier integer if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier binary_operator string string_start string_content escape_sequence string_end parenthesized_expression binary_operator string string_start string_content string_end integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier binary_operator string string_start string_content string_end identifier else_clause block expression_statement assignment identifier binary_operator string string_start string_content string_end subscript identifier integer return_statement identifier
calculate desc string, wrapped if too long
def _write_cron_lines(user, lines): lines = [salt.utils.stringutils.to_str(_l) for _l in lines] path = salt.utils.files.mkstemp() if _check_instance_uid_match(user) or __grains__.get('os_family') in ('Solaris', 'AIX'): with salt.utils.files.fpopen(path, 'w+', uid=__salt__['file.user_to_uid'](user), mode=0o600) as fp_: fp_.writelines(lines) ret = __salt__['cmd.run_all'](_get_cron_cmdstr(path), runas=user, python_shell=False) else: with salt.utils.files.fpopen(path, 'w+', mode=0o600) as fp_: fp_.writelines(lines) ret = __salt__['cmd.run_all'](_get_cron_cmdstr(path, user), python_shell=False) os.remove(path) return ret
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list_comprehension call attribute attribute attribute identifier identifier identifier identifier argument_list identifier for_in_clause identifier identifier expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list if_statement boolean_operator call identifier argument_list identifier comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end tuple string string_start string_content string_end string string_start string_content string_end block with_statement with_clause with_item as_pattern call attribute attribute attribute identifier identifier identifier identifier argument_list identifier string string_start string_content string_end keyword_argument identifier call subscript identifier string string_start string_content string_end argument_list identifier keyword_argument identifier integer as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call subscript identifier string string_start string_content string_end argument_list call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier false else_clause block with_statement with_clause with_item as_pattern call attribute attribute attribute identifier identifier identifier identifier argument_list identifier string string_start string_content string_end keyword_argument identifier integer as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call subscript identifier string string_start string_content string_end argument_list call identifier argument_list identifier identifier keyword_argument identifier false expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Takes a list of lines to be committed to a user's crontab and writes it
def on_key_press(self, event): key = event.key if event.modifiers: return if self.enable_keyboard_pan and key in self._arrows: self._pan_keyboard(key) if key in self._pm: self._zoom_keyboard(key) if key == 'R': self.reset()
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier if_statement attribute identifier identifier block return_statement if_statement boolean_operator attribute identifier identifier comparison_operator identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list
Pan and zoom with the keyboard.
def commit(self): "Commit data to the storage." if self._meta.path: with open(self._meta.path, 'wb') as fd: raw = deepcopy(self.raw) lazy_indexes = self.lazy_indexes if not self._meta.lazy_indexes: for idx_name in lazy_indexes: del raw['indexes'][idx_name] for index_name, values in raw['indexes'].items(): for value, keys in values.items(): raw['indexes'][index_name][value] = list(keys) if not raw['indexes'] or self._meta.lazy_indexes: del raw['indexes'] try: fd.write(six.u(self.serialize(raw))) except TypeError: fd.write(six.b(self.serialize(raw)))
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end if_statement attribute attribute identifier identifier identifier block with_statement with_clause with_item as_pattern call identifier argument_list attribute attribute identifier identifier identifier string string_start string_content string_end as_pattern_target identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier attribute identifier identifier if_statement not_operator attribute attribute identifier identifier identifier block for_statement identifier identifier block delete_statement subscript subscript identifier string string_start string_content string_end identifier for_statement pattern_list identifier identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement assignment subscript subscript subscript identifier string string_start string_content string_end identifier identifier call identifier argument_list identifier if_statement boolean_operator not_operator subscript identifier string string_start string_content string_end attribute attribute identifier identifier identifier block delete_statement subscript identifier string string_start string_content string_end try_statement block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier except_clause identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier
Commit data to the storage.
def getLocalDatetime(date, time, tz=None, timeDefault=dt.time.max): localTZ = timezone.get_current_timezone() if tz is None or tz == localTZ: localDt = getAwareDatetime(date, time, tz, timeDefault) else: eventDt = getAwareDatetime(date, time, tz, timeDefault) localDt = eventDt.astimezone(localTZ) if time is None: localDt = getAwareDatetime(localDt.date(), None, localTZ, timeDefault) return localDt
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier attribute attribute identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement boolean_operator comparison_operator identifier none comparison_operator identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier identifier identifier else_clause block expression_statement assignment identifier call identifier argument_list identifier identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list none identifier identifier return_statement identifier
Get a datetime in the local timezone from date and optionally time
def return_collection(collection_type): def outer_func(func): @functools.wraps(func) def inner_func(self, *pargs, **kwargs): result = func(self, *pargs, **kwargs) return list(map(collection_type, result)) return inner_func return outer_func
module function_definition identifier parameters identifier block function_definition identifier parameters identifier block decorated_definition decorator call attribute identifier identifier argument_list identifier function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list identifier list_splat identifier dictionary_splat identifier return_statement call identifier argument_list call identifier argument_list identifier identifier return_statement identifier return_statement identifier
Change method return value from raw API output to collection of models
def lemmatize(text, lowercase=True, remove_stopwords=True): doc = nlp(text) if lowercase and remove_stopwords: lemmas = [t.lemma_.lower() for t in doc if not (t.is_stop or t.orth_.lower() in STOPWORDS)] elif lowercase: lemmas = [t.lemma_.lower() for t in doc] elif remove_stopwords: lemmas = [t.lemma_ for t in doc if not (t.is_stop or t.orth_.lower() in STOPWORDS)] else: lemmas = [t.lemma_ for t in doc] return lemmas
module function_definition identifier parameters identifier default_parameter identifier true default_parameter identifier true block expression_statement assignment identifier call identifier argument_list identifier if_statement boolean_operator identifier identifier block expression_statement assignment identifier list_comprehension call attribute attribute identifier identifier identifier argument_list for_in_clause identifier identifier if_clause not_operator parenthesized_expression boolean_operator attribute identifier identifier comparison_operator call attribute attribute identifier identifier identifier argument_list identifier elif_clause identifier block expression_statement assignment identifier list_comprehension call attribute attribute identifier identifier identifier argument_list for_in_clause identifier identifier elif_clause identifier block expression_statement assignment identifier list_comprehension attribute identifier identifier for_in_clause identifier identifier if_clause not_operator parenthesized_expression boolean_operator attribute identifier identifier comparison_operator call attribute attribute identifier identifier identifier argument_list identifier else_clause block expression_statement assignment identifier list_comprehension attribute identifier identifier for_in_clause identifier identifier return_statement identifier
Return the lemmas of the tokens in a text.
def backup(id): filename = dump_database(id) key = "{}.dump".format(id) bucket = user_s3_bucket() bucket.upload_file(filename, key) return _generate_s3_url(bucket, key)
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list identifier identifier return_statement call identifier argument_list identifier identifier
Backup the database to S3.
def create_wordpress(self, service_id, version_number, name, path, comment=None): body = self._formdata({ "name": name, "path": path, "comment": comment, }, FastlyWordpress.FIELDS) content = self._fetch("/service/%s/version/%d/wordpress" % (service_id, version_number), method="POST", body=body) return FastlyWordpress(self, content)
module function_definition identifier parameters identifier identifier identifier identifier identifier default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier identifier return_statement call identifier argument_list identifier identifier
Create a wordpress for the specified service and version.
def links(self): links = Links() links["self"] = Link.for_( self._operation, self._ns, qs=self._page.to_items(), **self._context ) return links
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier keyword_argument identifier call attribute attribute identifier identifier identifier argument_list dictionary_splat attribute identifier identifier return_statement identifier
Include a self link.
def post(self, *args): filepath = self.get_body_argument('filepath') if not self.fs.exists(filepath): raise tornado.web.HTTPError(404) Filewatcher.add_directory_to_watch(filepath) self.write({'msg':'Watcher added for {}'.format(filepath)})
module function_definition identifier parameters identifier list_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block raise_statement call attribute attribute identifier identifier identifier argument_list integer expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list identifier
Start a new filewatcher at the specified path.
def _check_dn(self, dn, attr_value): if dn is not None: self._error('Two lines starting with dn: in one record.') if not is_dn(attr_value): self._error('No valid string-representation of ' 'distinguished name %s.' % attr_value)
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end if_statement not_operator call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end identifier
Check dn attribute for issues.
def group_re(self): out = '' for token, data in self.tokens(): if token == 'TXT': out += re.escape(data) elif token == 'VAR': out += '(?P<%s>%s)' % (data[1], data[0]) elif token == 'ANON': out += '(?:%s)' % data return out
module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_end for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement comparison_operator identifier string string_start string_content string_end block expression_statement augmented_assignment identifier call attribute identifier identifier argument_list identifier elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement augmented_assignment identifier binary_operator string string_start string_content string_end tuple subscript identifier integer subscript identifier integer elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement augmented_assignment identifier binary_operator string string_start string_content string_end identifier return_statement identifier
Return a regexp pattern with named groups
def _AsList(arg): if (isinstance(arg, string_types) or not isinstance(arg, collections.Iterable)): return [arg] else: return list(arg)
module function_definition identifier parameters identifier block if_statement parenthesized_expression boolean_operator call identifier argument_list identifier identifier not_operator call identifier argument_list identifier attribute identifier identifier block return_statement list identifier else_clause block return_statement call identifier argument_list identifier
Encapsulates an argument in a list, if it's not already iterable.
def upload(ctx, yes=False): import callee version = callee.__version__ if version.endswith('-dev'): fatal("Can't upload a development version (%s) to PyPI!", version) if not yes: answer = input("Do you really want to upload to PyPI [y/N]? ") yes = answer.strip().lower() == 'y' if not yes: logging.warning("Aborted -- not uploading to PyPI.") return -2 logging.debug("Uploading version %s to PyPI...", version) setup_py_upload = ctx.run('python setup.py sdist upload') if not setup_py_upload.ok: fatal("Failed to upload version %s to PyPI!", version, cause=setup_py_upload) logging.info("PyPI upload completed successfully.") git_tag = ctx.run('git tag %s' % version) if not git_tag.ok: fatal("Failed to add a Git tag for uploaded version %s", version, cause=git_tag) git_push = ctx.run('git push && git push --tags') if not git_push.ok: fatal("Failed to push the release upstream.", cause=git_push)
module function_definition identifier parameters identifier default_parameter identifier false block import_statement dotted_name identifier 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 identifier argument_list string string_start string_content string_end identifier if_statement not_operator identifier block expression_statement assignment identifier call identifier argument_list string string_start string_content string_end expression_statement assignment identifier comparison_operator call attribute call attribute identifier identifier argument_list identifier argument_list string string_start string_content string_end if_statement not_operator identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement unary_operator integer expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement not_operator attribute identifier identifier block expression_statement call identifier argument_list string string_start string_content string_end identifier keyword_argument identifier identifier 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 binary_operator string string_start string_content string_end identifier if_statement not_operator attribute identifier identifier block expression_statement call identifier argument_list string string_start string_content string_end identifier keyword_argument identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement not_operator attribute identifier identifier block expression_statement call identifier argument_list string string_start string_content string_end keyword_argument identifier identifier
Upload the package to PyPI.
def _read_content(self, response: Response, original_url_info: URLInfo): data = response.body.read(4096) url_info = original_url_info try: self._robots_txt_pool.load_robots_txt(url_info, data) except ValueError: _logger.warning(__( _('Failed to parse {url} for robots exclusion rules. ' 'Ignoring.'), url_info.url)) self._accept_as_blank(url_info) else: _logger.debug(__('Got a good robots.txt for {0}.', url_info.url))
module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_parameter identifier type identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list integer expression_statement assignment identifier identifier try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list identifier identifier except_clause identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list call identifier argument_list string string_start string_content string_end attribute identifier identifier
Read response and parse the contents into the pool.
def access(self, accessor, timeout=None): if self.loop.is_running(): raise RuntimeError("Loop is already running") coro = asyncio.wait_for(accessor, timeout, loop=self.loop) return self.loop.run_until_complete(coro)
module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement call attribute attribute identifier identifier identifier argument_list block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier keyword_argument identifier attribute identifier identifier return_statement call attribute attribute identifier identifier identifier argument_list identifier
Return a result from an asyncio future.
def _density_par(self,dangle,tdisrupt=None): if tdisrupt is None: tdisrupt= self._tdisrupt dOmin= dangle/tdisrupt return 0.5\ *(1.+special.erf((self._meandO-dOmin)\ /numpy.sqrt(2.*self._sortedSigOEig[2])))
module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier binary_operator identifier identifier return_statement binary_operator float line_continuation parenthesized_expression binary_operator float call attribute identifier identifier argument_list binary_operator parenthesized_expression binary_operator attribute identifier identifier identifier line_continuation call attribute identifier identifier argument_list binary_operator float subscript attribute identifier identifier integer
The raw density as a function of parallel angle
def split_str(string): split = string.split(' ') return ' '.join(split[:len(split) // 2]), ' '.join(split[len(split) // 2:])
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end return_statement expression_list call attribute string string_start string_content string_end identifier argument_list subscript identifier slice binary_operator call identifier argument_list identifier integer call attribute string string_start string_content string_end identifier argument_list subscript identifier slice binary_operator call identifier argument_list identifier integer
Split string in half to return two strings
def _json_to_supported(response_body): data = json.loads(response_body) supported = [] for supported_data in data.get("supportedList", []): supported.append(Supported().from_json( supported_data)) return supported
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier list for_statement identifier call attribute identifier identifier argument_list string string_start string_content string_end list block expression_statement call attribute identifier identifier argument_list call attribute call identifier argument_list identifier argument_list identifier return_statement identifier
Returns a list of Supported objects
def run_restore(self, snapshot: Dict[Union[str, Key], Any]) -> 'BaseItemCollection': try: for name, snap in snapshot.items(): if isinstance(name, Key): self._nested_items[name.group].run_restore(snap) else: self._nested_items[name].run_restore(snap) return self except Exception as e: raise SnapshotError('Error while restoring snapshot: {}'.format(self._snapshot)) from e
module function_definition identifier parameters identifier typed_parameter identifier type generic_type identifier type_parameter type generic_type identifier type_parameter type identifier type identifier type identifier type string string_start string_content string_end block try_statement block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement call identifier argument_list identifier identifier block expression_statement call attribute subscript attribute identifier identifier attribute identifier identifier identifier argument_list identifier else_clause block expression_statement call attribute subscript attribute identifier identifier identifier identifier argument_list identifier return_statement identifier except_clause as_pattern identifier as_pattern_target identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier identifier
Restores the state of a collection from a snapshot
def split_feature(f, n): if not isinstance(n, int): raise ValueError('n must be an integer') orig_feature = copy(f) step = (f.stop - f.start) / n for i in range(f.start, f.stop, step): f = copy(orig_feature) start = i stop = min(i + step, orig_feature.stop) f.start = start f.stop = stop yield f if stop == orig_feature.stop: break
module function_definition identifier parameters identifier identifier block if_statement not_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier binary_operator parenthesized_expression binary_operator attribute identifier identifier attribute identifier identifier identifier for_statement identifier call identifier argument_list attribute identifier identifier attribute identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier identifier expression_statement assignment identifier call identifier argument_list binary_operator identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement yield identifier if_statement comparison_operator identifier attribute identifier identifier block break_statement
Split an interval into `n` roughly equal portions
def download_metadata_file(self, outdir, force_rerun=False): uniprot_xml_file = download_uniprot_file(uniprot_id=self.id, outdir=outdir, filetype='xml', force_rerun=force_rerun) self.metadata_path = uniprot_xml_file
module function_definition identifier parameters identifier identifier default_parameter identifier false block expression_statement assignment identifier call identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier identifier expression_statement assignment attribute identifier identifier identifier
Download and load the UniProt XML file
def lexical_parent(self): if not hasattr(self, '_lexical_parent'): self._lexical_parent = conf.lib.clang_getCursorLexicalParent(self) return self._lexical_parent
module function_definition identifier parameters identifier block if_statement not_operator call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list identifier return_statement attribute identifier identifier
Return the lexical parent for this cursor.
def _update_record(self, identifier, rtype=None, name=None, content=None): if identifier is not None: if name is not None: records = self._list_records_internal(identifier=identifier) if len(records) == 1 and records[0]['name'] != self._full_name(name): self._update_record_with_name( records[0], rtype, name, content) else: self._update_record_with_id(identifier, rtype, content) else: self._update_record_with_id(identifier, rtype, content) else: guessed_record = self._guess_record(rtype, name) self._update_record_with_id(guessed_record['id'], rtype, content) return True
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none block if_statement comparison_operator identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier if_statement boolean_operator comparison_operator call identifier argument_list identifier integer comparison_operator subscript subscript identifier integer string string_start string_content string_end call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list subscript identifier integer identifier identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier identifier identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end identifier identifier return_statement true
Updates a record. Name changes are allowed, but the record identifier will change
def _find_cmd(self, cmd): cdir = self.get_install_cassandra_root() if self.get_base_cassandra_version() >= 2.1: fcmd = common.join_bin(cdir, os.path.join('tools', 'bin'), cmd) else: fcmd = common.join_bin(cdir, 'bin', cmd) try: if os.path.exists(fcmd): os.chmod(fcmd, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR | stat.S_IRGRP | stat.S_IXGRP | stat.S_IROTH | stat.S_IXOTH) except: common.warning("Couldn't change permissions to use {0}.".format(cmd)) common.warning("If it didn't work, you will have to do so manually.") return fcmd
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator call attribute identifier identifier argument_list float block expression_statement assignment identifier call attribute identifier identifier argument_list identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end identifier try_statement block if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier except_clause block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement identifier
Locates command under cassandra root and fixes permissions if needed
def prt_results(self, goea_results): if self.args.outfile is None: self._prt_results(goea_results) else: outfiles = self.args.outfile.split(",") grpwr = self.prepgrp.get_objgrpwr(goea_results) if self.prepgrp else None if grpwr is None: self.prt_outfiles_flat(goea_results, outfiles) else: grpwr.prt_outfiles_grouped(outfiles)
module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute attribute identifier identifier identifier none block expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier conditional_expression call attribute attribute identifier identifier identifier argument_list identifier attribute identifier identifier none if_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier
Print GOEA results to the screen or to a file.