code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def dataset_splits(self): return [{ "split": problem.DatasetSplit.TRAIN, "shards": _TRAIN_SHARDS, }, { "split": problem.DatasetSplit.EVAL, "shards": _DEV_SHARDS, }]
module function_definition identifier parameters identifier block return_statement list dictionary pair string string_start string_content string_end attribute attribute identifier identifier identifier pair string string_start string_content string_end identifier dictionary pair string string_start string_content string_end attribute attribute identifier identifier identifier pair string string_start string_content string_end identifier
Splits of data to produce and number of output shards for each.
def do_allowrep(self, line): self._split_args(line, 0, 0) self._command_processor.get_session().get_replication_policy().set_replication_allowed( True ) self._print_info_if_verbose("Set replication policy to allow replication")
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list identifier integer integer expression_statement call attribute call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list identifier argument_list true expression_statement call attribute identifier identifier argument_list string string_start string_content string_end
allowrep Allow new objects to be replicated.
def epoch(ctx, datetime): return conversions.to_decimal(str(conversions.to_datetime(datetime, ctx).timestamp()), ctx)
module function_definition identifier parameters identifier identifier block return_statement call attribute identifier identifier argument_list call identifier argument_list call attribute call attribute identifier identifier argument_list identifier identifier identifier argument_list identifier
Converts the given date to the number of seconds since January 1st, 1970 UTC
def main(): _parse_args() LOG.info("Starting: %s", __service_id__) LOG.info('Subscribing to state change events (subscriber = %s)', __service_name__) sdp_state = SDPState() _ = sdp_state.subscribe(subscriber=__service_name__) _ = _init(sdp_state) LOG.info('Finished initialising!') LOG.info('Responding to state change events ...') try: _process_state_change_events() except ValueError as error: LOG.critical('Value error: %s', str(error)) except KeyboardInterrupt as err: LOG.debug('Keyboard Interrupt %s', err) LOG.info('Exiting!')
module function_definition identifier parameters block expression_statement call identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end try_statement block expression_statement call identifier argument_list except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end
Merge temp_main and main.
def getFullPathToSnapshot(self, n): return os.path.join(self.snapDir, str(n))
module function_definition identifier parameters identifier identifier block return_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier call identifier argument_list identifier
Get the full path to snapshot n.
def restore_type(self, type): mapping = { 'BOOLEAN': 'boolean', 'DATE': 'date', 'DATETIME': 'datetime', 'INTEGER': 'integer', 'FLOAT': 'number', 'STRING': 'string', 'TIME': 'time', } if type not in mapping: message = 'Type %s is not supported' % type raise tableschema.exceptions.StorageError(message) return mapping[type]
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end if_statement comparison_operator identifier identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end identifier raise_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement subscript identifier identifier
Restore type from BigQuery
def parse_yaml(self, y): self.name = y['name'] if RTS_EXT_NS_YAML + 'comment' in y: self.comment = y[RTS_EXT_NS_YAML + 'comment'] if RTS_EXT_NS_YAML + 'visible' in y: visible = y.get(RTS_EXT_NS_YAML + 'visible') if visible == True or visible == 'true' or visible == 'True': self.visible = True else: self.visible = False if RTS_EXT_NS_YAML + 'properties' in y: for p in y.get(RTS_EXT_NS_YAML + 'properties'): if 'value' in p: value = p['value'] else: value = None self._properties[p['name']] = value return self
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier subscript identifier string string_start string_content string_end if_statement comparison_operator binary_operator identifier string string_start string_content string_end identifier block expression_statement assignment attribute identifier identifier subscript identifier binary_operator identifier string string_start string_content string_end if_statement comparison_operator binary_operator identifier string string_start string_content string_end identifier block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator identifier string string_start string_content string_end if_statement boolean_operator boolean_operator comparison_operator identifier true comparison_operator identifier string string_start string_content string_end comparison_operator identifier string string_start string_content string_end block expression_statement assignment attribute identifier identifier true else_clause block expression_statement assignment attribute identifier identifier false if_statement comparison_operator binary_operator identifier string string_start string_content string_end identifier block for_statement identifier call attribute identifier identifier argument_list binary_operator identifier string string_start string_content string_end 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 else_clause block expression_statement assignment identifier none expression_statement assignment subscript attribute identifier identifier subscript identifier string string_start string_content string_end identifier return_statement identifier
Parse a YAML specification of a data port into this object.
def __merge_json_values(current, previous): for value in current: name = value['name'] previous_value = __find_and_remove_value(previous, value) if previous_value is not None: flags = value['flags'] previous_flags = previous_value['flags'] if flags != previous_flags: logging.warning( 'Flags for %s are different. Using previous value.', name) value['flags'] = previous_flags else: logging.warning('Value %s is a new value', name) for value in previous: name = value['name'] logging.warning( 'Value %s not present in current run. Appending value.', name) current.append(value)
module function_definition identifier parameters identifier identifier block for_statement identifier identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier string string_start string_content string_end if_statement comparison_operator identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier for_statement identifier identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier
Merges the values between the current and previous run of the script.
def check_no_proxy_errors(self, **kwargs): data = self._es.search(body={ "size": max_query_results, "query": { "filtered": { "query": { "match_all": {} }, "filter": { "term": { "level": "error" } } } } }) return GremlinTestResult(data["hits"]["total"] == 0, data)
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end dictionary pair string string_start string_content string_end dictionary pair string string_start string_content string_end dictionary pair string string_start string_content string_end dictionary pair string string_start string_content string_end dictionary pair string string_start string_content string_end dictionary pair string string_start string_content string_end string string_start string_content string_end return_statement call identifier argument_list comparison_operator subscript subscript identifier string string_start string_content string_end string string_start string_content string_end integer identifier
Helper method to determine if the proxies logged any major errors related to the functioning of the proxy itself
def create_blobstore(self, **kwargs): blobstore = predix.admin.blobstore.BlobStore(**kwargs) blobstore.create() blobstore.add_to_manifest(self) return blobstore
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list dictionary_splat identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Creates an instance of the BlobStore Service.
def temporarySibling(self): sib = self.parent().child(_secureEnoughString() + self.basename()) sib.requireCreate() return sib
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list binary_operator call identifier argument_list call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list return_statement identifier
Create a path naming a temporary sibling of this path in a secure fashion.
def api_representation(self): return dict(EmailAddress=dict(Name=self.name, Address=self.email))
module function_definition identifier parameters identifier block return_statement call identifier argument_list keyword_argument identifier call identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier
Returns the JSON formatting required by Outlook's API for contacts
def contains_array(store, path=None): path = normalize_storage_path(path) prefix = _path_to_prefix(path) key = prefix + array_meta_key return key in store
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier binary_operator identifier identifier return_statement comparison_operator identifier identifier
Return True if the store contains an array at the given logical path.
def __meta_metadata(self, field, key): mf = '' try: mf = str([f[key] for f in self.metadata if f['field_name'] == field][0]) except IndexError: print("%s not in metadata field:%s" % (key, field)) return mf else: return mf
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier string string_start string_end try_statement block expression_statement assignment identifier call identifier argument_list subscript list_comprehension subscript identifier identifier for_in_clause identifier attribute identifier identifier if_clause comparison_operator subscript identifier string string_start string_content string_end identifier integer except_clause identifier block expression_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier return_statement identifier else_clause block return_statement identifier
Return the value for key for the field in the metadata
def filter( names, pat ): import os, posixpath result = [ ] pat = os.path.normcase( pat ) if not pat in _cache: res = translate( pat ) if len( _cache ) >= _MAXCACHE: _cache.clear( ) _cache[ pat ] = re.compile( res ) match = _cache[ pat ].match if os.path is posixpath: for name in names: if match( name ): result.append( name ) else: for name in names: if match( os.path.normcase( name ) ): result.append( name ) return result
module function_definition identifier parameters identifier identifier block import_statement dotted_name identifier dotted_name identifier expression_statement assignment identifier list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement not_operator comparison_operator identifier identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment subscript identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier attribute subscript identifier identifier identifier if_statement comparison_operator attribute identifier identifier identifier block for_statement identifier identifier block if_statement call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier else_clause block for_statement identifier identifier block if_statement call identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Return the subset of the list NAMES that match PAT
def fcor(self): if self.XCBV is None: return None else: return self.flux - self._mission.FitCBVs(self)
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block return_statement none else_clause block return_statement binary_operator attribute identifier identifier call attribute attribute identifier identifier identifier argument_list identifier
The CBV-corrected de-trended flux.
def function_is_noop(function_node: ast.FunctionDef) -> bool: return all(node_is_noop(n) for n in function_node.body)
module function_definition identifier parameters typed_parameter identifier type attribute identifier identifier type identifier block return_statement call identifier generator_expression call identifier argument_list identifier for_in_clause identifier attribute identifier identifier
Function does nothing - is just ``pass`` or docstring.
def bind(cls, app, *paths, methods=None, name=None, router=None, view=None): cls.app = app if cls.app is not None: for _, m in inspect.getmembers(cls, predicate=inspect.isfunction): if not hasattr(m, ROUTE_PARAMS_ATTR): continue paths_, methods_, name_ = getattr(m, ROUTE_PARAMS_ATTR) name_ = name_ or ("%s.%s" % (cls.name, m.__name__)) delattr(m, ROUTE_PARAMS_ATTR) cls.app.register(*paths_, methods=methods_, name=name_, handler=cls)(m) @coroutine @functools.wraps(cls) def handler(request): return cls().dispatch(request, view=view) if not paths: paths = ["/%s" % cls.__name__] return routes_register( app, handler, *paths, methods=methods, router=router, name=name or cls.name)
module function_definition identifier parameters identifier identifier list_splat_pattern identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none block expression_statement assignment attribute identifier identifier identifier if_statement comparison_operator attribute identifier identifier none block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier block if_statement not_operator call identifier argument_list identifier identifier block continue_statement expression_statement assignment pattern_list identifier identifier identifier call identifier argument_list identifier identifier expression_statement assignment identifier boolean_operator identifier parenthesized_expression binary_operator string string_start string_content string_end tuple attribute identifier identifier attribute identifier identifier expression_statement call identifier argument_list identifier identifier expression_statement call call attribute attribute identifier identifier identifier argument_list list_splat identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier argument_list identifier decorated_definition decorator identifier decorator call attribute identifier identifier argument_list identifier function_definition identifier parameters identifier block return_statement call attribute call identifier argument_list identifier argument_list identifier keyword_argument identifier identifier if_statement not_operator identifier block expression_statement assignment identifier list binary_operator string string_start string_content string_end attribute identifier identifier return_statement call identifier argument_list identifier identifier list_splat identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier boolean_operator identifier attribute identifier identifier
Bind to the given application.
def create_from_ll(cls, lls:LabelLists, bs:int=64, val_bs:int=None, ds_tfms:Optional[TfmList]=None, num_workers:int=defaults.cpus, dl_tfms:Optional[Collection[Callable]]=None, device:torch.device=None, test:Optional[PathOrStr]=None, collate_fn:Callable=data_collate, size:int=None, no_check:bool=False, resize_method:ResizeMethod=None, mult:int=None, padding_mode:str='reflection', mode:str='bilinear', tfm_y:bool=False)->'ImageDataBunch': "Create an `ImageDataBunch` from `LabelLists` `lls` with potential `ds_tfms`." lls = lls.transform(tfms=ds_tfms, size=size, resize_method=resize_method, mult=mult, padding_mode=padding_mode, mode=mode, tfm_y=tfm_y) if test is not None: lls.add_test_folder(test) return lls.databunch(bs=bs, val_bs=val_bs, dl_tfms=dl_tfms, num_workers=num_workers, collate_fn=collate_fn, device=device, no_check=no_check)
module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_default_parameter identifier type identifier integer typed_default_parameter identifier type identifier none typed_default_parameter identifier type generic_type identifier type_parameter type identifier none typed_default_parameter identifier type identifier attribute identifier identifier typed_default_parameter identifier type generic_type identifier type_parameter type generic_type identifier type_parameter type identifier none typed_default_parameter identifier type attribute identifier identifier none typed_default_parameter identifier type generic_type identifier type_parameter type identifier none typed_default_parameter identifier type identifier identifier typed_default_parameter identifier type identifier none typed_default_parameter identifier type identifier false typed_default_parameter identifier type identifier none typed_default_parameter identifier type identifier none typed_default_parameter identifier type identifier string string_start string_content string_end typed_default_parameter identifier type identifier string string_start string_content string_end typed_default_parameter identifier type identifier false type string string_start string_content string_end block expression_statement string string_start string_content string_end 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 keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier if_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
Create an `ImageDataBunch` from `LabelLists` `lls` with potential `ds_tfms`.
def form_echo(cls, request, foo: (Ptypes.form, String('A form parameter'))) -> [ (200, 'Ok', String)]: log.info('Echoing form param, value is: {}'.format(foo)) for i in range(randint(0, MAX_LOOP_DURATION)): yield msg = 'The value sent was: {}'.format(foo) Respond(200, msg)
module function_definition identifier parameters identifier identifier typed_parameter identifier type tuple attribute identifier identifier call identifier argument_list string string_start string_content string_end type list tuple integer string string_start string_content string_end identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier for_statement identifier call identifier argument_list call identifier argument_list integer identifier block expression_statement yield expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call identifier argument_list integer identifier
Echo the form parameter.
def _iter_coords(nsls): ranges = list() for nsl in nsls: if isinstance(nsl, int): ranges.append(range(nsl, nsl+1)) else: ranges.append(range(nsl.start, nsl.stop)) yield from itertools.product(*ranges)
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list for_statement identifier identifier block if_statement call identifier argument_list identifier identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier binary_operator identifier integer else_clause block expression_statement call attribute identifier identifier argument_list call identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement yield call attribute identifier identifier argument_list list_splat identifier
Iterate through all matching coordinates in a sequence of slices.
def request(self, app_id=None, body=None, stamp=None, url=None, sig=None): if self.app_id: if not self.application_id(app_id): return False if (url or sig): if not (body and stamp and url and sig): raise ValueError('Unable to validate sender, check arguments.') else: if not self.sender(body, stamp, url, sig): return False return True
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none block if_statement attribute identifier identifier block if_statement not_operator call attribute identifier identifier argument_list identifier block return_statement false if_statement parenthesized_expression boolean_operator identifier identifier block if_statement not_operator parenthesized_expression boolean_operator boolean_operator boolean_operator identifier identifier identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end else_clause block if_statement not_operator call attribute identifier identifier argument_list identifier identifier identifier identifier block return_statement false return_statement true
Validate application ID and request is from Alexa.
def resizeToMinimum(self): offset = self.padding() min_size = self.minimumPixmapSize() if self.position() in (XDockToolbar.Position.East, XDockToolbar.Position.West): self.resize(min_size.width() + offset, self.height()) elif self.position() in (XDockToolbar.Position.North, XDockToolbar.Position.South): self.resize(self.width(), min_size.height() + offset)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator call attribute identifier identifier argument_list tuple attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list elif_clause comparison_operator call attribute identifier identifier argument_list tuple attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list binary_operator call attribute identifier identifier argument_list identifier
Resizes the dock toolbar to the minimum sizes.
def to_python(self, value): value = super(BoundingBoxField, self).to_python(value) try: bbox = gdal.OGRGeometry.from_bbox(value).geos except (ValueError, AttributeError): return [] bbox.srid = self.srid return bbox
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute call identifier argument_list identifier identifier identifier argument_list identifier try_statement block expression_statement assignment identifier attribute call attribute attribute identifier identifier identifier argument_list identifier identifier except_clause tuple identifier identifier block return_statement list expression_statement assignment attribute identifier identifier attribute identifier identifier return_statement identifier
Returns a GEOS Polygon from bounding box values.
def visit_keyword(self, node, parent): newnode = nodes.Keyword(node.arg, parent=parent) newnode.postinit(self.visit(node.value, newnode)) return newnode
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier identifier return_statement identifier
visit a Keyword node by returning a fresh instance of it
def __dict_to_deployment_spec(spec): spec_obj = AppsV1beta1DeploymentSpec(template=spec.get('template', '')) for key, value in iteritems(spec): if hasattr(spec_obj, key): setattr(spec_obj, key, value) return spec_obj
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end for_statement pattern_list identifier identifier call identifier argument_list identifier block if_statement call identifier argument_list identifier identifier block expression_statement call identifier argument_list identifier identifier identifier return_statement identifier
Converts a dictionary into kubernetes AppsV1beta1DeploymentSpec instance.
def align(self, out_path=None): if out_path is None: out_path = self.prefix_path + '.aln' sh.muscle38("-in", self.path, "-out", out_path) return AlignedFASTA(out_path)
module function_definition identifier parameters identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier binary_operator attribute identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier string string_start string_content string_end identifier return_statement call identifier argument_list identifier
We align the sequences in the fasta file with muscle.
def split_hostmask(hostmask): nick, _, host = hostmask.partition('@') nick, _, user = nick.partition('!') return nick, user or None, host or None
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment pattern_list identifier identifier identifier call attribute identifier identifier argument_list string string_start string_content string_end return_statement expression_list identifier boolean_operator identifier none boolean_operator identifier none
Splits a nick@host string into nick and host.
def _clean_post_content(blog_url, content): content = re.sub( "<img.src=\"%s(.*)\"" % blog_url, lambda s: "<img src=\"%s\"" % _get_relative_upload(s.groups(1)[0]), content) return content
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator string string_start string_content escape_sequence escape_sequence string_end identifier lambda lambda_parameters identifier binary_operator string string_start string_content escape_sequence escape_sequence string_end call identifier argument_list subscript call attribute identifier identifier argument_list integer integer identifier return_statement identifier
Replace import path with something relative to blog.
def go_down(self): if self.current_option < len(self.items) - 1: self.current_option += 1 else: self.current_option = 0 self.draw()
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier binary_operator call identifier argument_list attribute identifier identifier integer block expression_statement augmented_assignment attribute identifier identifier integer else_clause block expression_statement assignment attribute identifier identifier integer expression_statement call attribute identifier identifier argument_list
Go down one, wrap to beginning if necessary
def index_bounds(x): if isinstance(x, (pd.DataFrame, pd.Series)): return x.iloc[0], x.iloc[-1] else: return x[0], x[-1]
module function_definition identifier parameters identifier block if_statement call identifier argument_list identifier tuple attribute identifier identifier attribute identifier identifier block return_statement expression_list subscript attribute identifier identifier integer subscript attribute identifier identifier unary_operator integer else_clause block return_statement expression_list subscript identifier integer subscript identifier unary_operator integer
returns tuple with first and last item
def trim(self, prefixes): "Prunes any keys beginning with the specified the specified prefixes." _prefixes, prefixes = set(map(lambda k:self._prepare_key(k), prefixes)), list() for t in lookahead(sorted(_prefixes)): if t[1] is not None: if t[0] == commonprefix(t): continue prefixes.append(t[0]) length = 0 for prefix in prefixes: length += self._trim(prefix) return length
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end expression_statement assignment pattern_list identifier identifier expression_list call identifier argument_list call identifier argument_list lambda lambda_parameters identifier call attribute identifier identifier argument_list identifier identifier call identifier argument_list for_statement identifier call identifier argument_list call identifier argument_list identifier block if_statement comparison_operator subscript identifier integer none block if_statement comparison_operator subscript identifier integer call identifier argument_list identifier block continue_statement expression_statement call attribute identifier identifier argument_list subscript identifier integer expression_statement assignment identifier integer for_statement identifier identifier block expression_statement augmented_assignment identifier call attribute identifier identifier argument_list identifier return_statement identifier
Prunes any keys beginning with the specified the specified prefixes.
def config_acl(args): r = fapi.get_repository_config_acl(args.namespace, args.config, args.snapshot_id) fapi._check_response_code(r, 200) acls = sorted(r.json(), key=lambda k: k['user']) return map(lambda acl: '{0}\t{1}'.format(acl['user'], acl['role']), acls)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier integer expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier lambda lambda_parameters identifier subscript identifier string string_start string_content string_end return_statement call identifier argument_list lambda lambda_parameters identifier call attribute string string_start string_content escape_sequence string_end identifier argument_list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end identifier
Retrieve access control list for a method configuration
def map_exception_codes(): werkex = inspect.getmembers(exceptions, lambda x: getattr(x, 'code', None)) return {e.code: e for _, e in werkex}
module function_definition identifier parameters block expression_statement assignment identifier call attribute identifier identifier argument_list identifier lambda lambda_parameters identifier call identifier argument_list identifier string string_start string_content string_end none return_statement dictionary_comprehension pair attribute identifier identifier identifier for_in_clause pattern_list identifier identifier identifier
Helper function to intialise CODES_TO_EXCEPTIONS.
def default_config_filename(root_dir=None): root_dir = Path(root_dir) if root_dir else Path('.').abspath() locale_dir = root_dir / 'locale' if not os.path.exists(locale_dir): locale_dir = root_dir / 'conf' / 'locale' return locale_dir / BASE_CONFIG_FILENAME
module function_definition identifier parameters default_parameter identifier none block expression_statement assignment identifier conditional_expression call identifier argument_list identifier identifier call attribute call identifier argument_list string string_start string_content string_end identifier argument_list expression_statement assignment identifier binary_operator identifier string string_start string_content string_end if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement assignment identifier binary_operator binary_operator identifier string string_start string_content string_end string string_start string_content string_end return_statement binary_operator identifier identifier
Returns the default name of the configuration file.
def show_loading_page(self): loading_template = Template(LOADING) loading_img = get_image_path('loading_sprites.png') if os.name == 'nt': loading_img = loading_img.replace('\\', '/') message = _("Connecting to kernel...") page = loading_template.substitute(css_path=CSS_PATH, loading_img=loading_img, message=message) self.setHtml(page)
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list string string_start string_content string_end if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end string string_start string_content string_end expression_statement assignment identifier call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list identifier
Show a loading animation while the kernel is starting.
def add_plugin(self, plugin): new_name = self.plugin_name(plugin) self._plugins[:] = [p for p in self._plugins if self.plugin_name(p) != new_name] self._plugins.append(plugin)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment subscript attribute identifier identifier slice list_comprehension identifier for_in_clause identifier attribute identifier identifier if_clause comparison_operator call attribute identifier identifier argument_list identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Add the given plugin.
def validate(cls, data): try: jsonschema.validate( data, cls.SCHEMA, types={'array': (list, tuple)}) except jsonschema.ValidationError as e: raise InvalidFormat("Failure data not of the" " expected format: %s" % (e.message)) else: causes = collections.deque([data]) while causes: cause = causes.popleft() try: generated_on = cause['generated_on'] ok_bases = cls.BASE_EXCEPTIONS[generated_on[0]] except (KeyError, IndexError): ok_bases = [] root_exc_type = cause['exc_type_names'][-1] if root_exc_type not in ok_bases: raise InvalidFormat( "Failure data 'exc_type_names' must" " have an initial exception type that is one" " of %s types: '%s' is not one of those" " types" % (ok_bases, root_exc_type)) sub_cause = cause.get('cause') if sub_cause is not None: causes.append(sub_cause)
module function_definition identifier parameters identifier identifier block try_statement block expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier keyword_argument identifier dictionary pair string string_start string_content string_end tuple identifier identifier except_clause as_pattern attribute identifier identifier as_pattern_target identifier block raise_statement call identifier argument_list binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end parenthesized_expression attribute identifier identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list list identifier while_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list try_statement block expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier subscript attribute identifier identifier subscript identifier integer except_clause tuple identifier identifier block expression_statement assignment identifier list expression_statement assignment identifier subscript subscript identifier string string_start string_content string_end unary_operator integer if_statement comparison_operator identifier identifier block raise_statement call identifier argument_list binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end tuple identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list identifier
Validate input data matches expected failure ``dict`` format.
def _length_scalar_handler(scalar_factory, ion_type, length, ctx): _, self = yield if length == 0: data = b'' else: yield ctx.read_data_transition(length, self) data = ctx.queue.read(length) scalar = scalar_factory(data) event_cls = IonEvent if callable(scalar): event_cls = IonThunkEvent yield ctx.event_transition(event_cls, IonEventType.SCALAR, ion_type, scalar)
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment pattern_list identifier identifier yield if_statement comparison_operator identifier integer block expression_statement assignment identifier string string_start string_end else_clause block expression_statement yield call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier identifier if_statement call identifier argument_list identifier block expression_statement assignment identifier identifier expression_statement yield call attribute identifier identifier argument_list identifier attribute identifier identifier identifier identifier
Handles scalars, ``scalar_factory`` is a function that returns a value or thunk.
def with_condition(self, condition: Callable[[MonitorContext], bool]) -> 'MonitorTask': self._condition = condition return self
module function_definition identifier parameters identifier typed_parameter identifier type generic_type identifier type_parameter type list identifier type identifier type string string_start string_content string_end block expression_statement assignment attribute identifier identifier identifier return_statement identifier
Sets the task running condition that will be evaluated during the optimisation cycle.
def _warn_silly_options(cls, args): if 'page-requisites' in args.span_hosts_allow \ and not args.page_requisites: _logger.warning( _('Spanning hosts is allowed for page requisites, ' 'but the page requisites option is not on.') ) if 'linked-pages' in args.span_hosts_allow \ and not args.recursive: _logger.warning( _('Spanning hosts is allowed for linked pages, ' 'but the recursive option is not on.') ) if args.warc_file and \ (args.http_proxy or args.https_proxy): _logger.warning(_('WARC specifications do not handle proxies.')) if (args.password or args.ftp_password or args.http_password or args.proxy_password) and \ args.warc_file: _logger.warning( _('Your password is recorded in the WARC file.'))
module function_definition identifier parameters identifier identifier block if_statement boolean_operator comparison_operator string string_start string_content string_end attribute identifier identifier line_continuation not_operator attribute identifier identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end if_statement boolean_operator comparison_operator string string_start string_content string_end attribute identifier identifier line_continuation not_operator attribute identifier identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end if_statement boolean_operator attribute identifier identifier line_continuation parenthesized_expression boolean_operator attribute identifier identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list string string_start string_content string_end if_statement boolean_operator parenthesized_expression boolean_operator boolean_operator boolean_operator attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier line_continuation attribute identifier identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list string string_start string_content string_end
Print warnings about any options that may be silly.
def _notify(p, **data): message = data.get("message") if not message and not sys.stdin.isatty(): message = click.get_text_stream("stdin").read() data["message"] = message data = clean_data(data) ctx = click.get_current_context() if ctx.obj.get("env_prefix"): data["env_prefix"] = ctx.obj["env_prefix"] rsp = p.notify(**data) rsp.raise_on_errors() click.secho(f"Succesfully sent a notification to {p.name}!", fg="green")
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement boolean_operator not_operator identifier not_operator call attribute attribute identifier identifier identifier argument_list block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list string string_start string_content string_end identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list if_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end block expression_statement assignment subscript identifier string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list dictionary_splat identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content interpolation attribute identifier identifier string_content string_end keyword_argument identifier string string_start string_content string_end
The callback func that will be hooked to the ``notify`` command
def init_git_pillar(opts): ret = [] for opts_dict in [x for x in opts.get('ext_pillar', [])]: if 'git' in opts_dict: try: pillar = salt.utils.gitfs.GitPillar( opts, opts_dict['git'], per_remote_overrides=git_pillar.PER_REMOTE_OVERRIDES, per_remote_only=git_pillar.PER_REMOTE_ONLY, global_only=git_pillar.GLOBAL_ONLY) ret.append(pillar) except salt.exceptions.FileserverConfigError: if opts.get('git_pillar_verify_config', True): raise else: log.critical('Could not initialize git_pillar') return ret
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier list_comprehension identifier for_in_clause identifier call attribute identifier identifier argument_list string string_start string_content string_end list block if_statement comparison_operator string string_start string_content string_end identifier block try_statement block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list identifier subscript identifier string string_start string_content string_end keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier except_clause attribute attribute identifier identifier identifier block if_statement call attribute identifier identifier argument_list string string_start string_content string_end true block raise_statement else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement identifier
Clear out the ext pillar caches, used when the master starts
def filter_cookies(self, request_url: URL=URL()) -> 'BaseCookie[str]': self._do_expiration() request_url = URL(request_url) filtered = SimpleCookie() hostname = request_url.raw_host or "" is_not_secure = request_url.scheme not in ("https", "wss") for cookie in self: name = cookie.key domain = cookie["domain"] if not domain: filtered[name] = cookie.value continue if not self._unsafe and is_ip_address(hostname): continue if (domain, name) in self._host_only_cookies: if domain != hostname: continue elif not self._is_domain_match(domain, hostname): continue if not self._is_path_match(request_url.path, cookie["path"]): continue if is_not_secure and cookie["secure"]: continue mrsl_val = cast('Morsel[str]', cookie.get(cookie.key, Morsel())) mrsl_val.set(cookie.key, cookie.value, cookie.coded_value) filtered[name] = mrsl_val return filtered
module function_definition identifier parameters identifier typed_default_parameter identifier type identifier call identifier argument_list type string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier boolean_operator attribute identifier identifier string string_start string_end expression_statement assignment identifier comparison_operator attribute identifier identifier tuple string string_start string_content string_end string string_start string_content string_end for_statement identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier subscript identifier string string_start string_content string_end if_statement not_operator identifier block expression_statement assignment subscript identifier identifier attribute identifier identifier continue_statement if_statement boolean_operator not_operator attribute identifier identifier call identifier argument_list identifier block continue_statement if_statement comparison_operator tuple identifier identifier attribute identifier identifier block if_statement comparison_operator identifier identifier block continue_statement elif_clause not_operator call attribute identifier identifier argument_list identifier identifier block continue_statement if_statement not_operator call attribute identifier identifier argument_list attribute identifier identifier subscript identifier string string_start string_content string_end block continue_statement if_statement boolean_operator identifier subscript identifier string string_start string_content string_end block continue_statement expression_statement assignment identifier call identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list attribute identifier identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement assignment subscript identifier identifier identifier return_statement identifier
Returns this jar's cookies filtered by their attributes.
def getThirdPartyLibFiles(self, libs): platformDefaults = True if libs[0] == '--nodefaults': platformDefaults = False libs = libs[1:] details = self.getThirdpartyLibs(libs, includePlatformDefaults=platformDefaults) return details.getLibraryFiles(self.getEngineRoot(), delimiter='\n')
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier true if_statement comparison_operator subscript identifier integer string string_start string_content string_end block expression_statement assignment identifier false expression_statement assignment identifier subscript identifier slice integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier return_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content escape_sequence string_end
Retrieves the list of library files for building against the Unreal-bundled versions of the specified third-party libraries
def _handle_dist_server(ds_type, repos_array): if ds_type not in ("JDS", "CDP"): raise ValueError("Must be JDS or CDP") prompt = "Does your JSS use a %s? (Y|N): " % ds_type result = loop_until_valid_response(prompt) if result: repo_dict = ElementTree.SubElement(repos_array, "dict") repo_name_key = ElementTree.SubElement(repo_dict, "key") repo_name_key.text = "type" repo_name_string = ElementTree.SubElement(repo_dict, "string") repo_name_string.text = ds_type
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier tuple string string_start string_content string_end string string_start string_content string_end block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier binary_operator string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list identifier if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier identifier
Ask user for whether to use a type of dist server.
def warning(lineno, msg): msg = "%s:%i: warning: %s" % (global_.FILENAME, lineno, msg) msg_output(msg) global_.has_warnings += 1
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple attribute identifier identifier identifier identifier expression_statement call identifier argument_list identifier expression_statement augmented_assignment attribute identifier identifier integer
Generic warning error routine
def users(self): if not hasattr(self, "_users"): us = {} if "users" in self.doc: for ur in self.doc["users"]: us[ur["name"]] = u = copy.deepcopy(ur["user"]) BytesOrFile.maybe_set(u, "client-certificate") BytesOrFile.maybe_set(u, "client-key") self._users = us return self._users
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 identifier dictionary if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block for_statement identifier subscript attribute identifier identifier string string_start string_content string_end block expression_statement assignment subscript identifier subscript identifier string string_start string_content string_end assignment identifier call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier identifier return_statement attribute identifier identifier
Returns known users by exposing as a read-only property.
def schedule(self): response = requests.get( "https://tccna.honeywell.com/WebAPI/emea/api/v1" "/%s/%s/schedule" % (self.zone_type, self.zoneId), headers=self.client._headers() ) response.raise_for_status() mapping = [ ('dailySchedules', 'DailySchedules'), ('dayOfWeek', 'DayOfWeek'), ('temperature', 'TargetTemperature'), ('timeOfDay', 'TimeOfDay'), ('switchpoints', 'Switchpoints'), ('dhwState', 'DhwState'), ] response_data = response.text for from_val, to_val in mapping: response_data = response_data.replace(from_val, to_val) data = json.loads(response_data) for day_of_week, schedule in enumerate(data['DailySchedules']): schedule['DayOfWeek'] = day_of_week return data
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end tuple attribute identifier identifier attribute identifier identifier keyword_argument identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier list tuple string string_start string_content string_end string string_start string_content string_end tuple string string_start string_content string_end string string_start string_content string_end tuple string string_start string_content string_end string string_start string_content string_end tuple string string_start string_content string_end string string_start string_content string_end tuple string string_start string_content string_end string string_start string_content string_end tuple string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier attribute identifier identifier for_statement pattern_list identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier for_statement pattern_list identifier identifier call identifier argument_list subscript identifier string string_start string_content string_end block expression_statement assignment subscript identifier string string_start string_content string_end identifier return_statement identifier
Gets the schedule for the given zone
def process(self): subscription = None result = None try: subscription = self.socket.recv() except AuthenticateError as exception: logging.error( 'Subscriber error while authenticating request: {}' .format(exception), exc_info=1) except AuthenticatorInvalidSignature as exception: logging.error( 'Subscriber error while authenticating request: {}' .format(exception), exc_info=1) except DecodeError as exception: logging.error( 'Subscriber error while decoding request: {}' .format(exception), exc_info=1) except RequestParseError as exception: logging.error( 'Subscriber error while parsing request: {}' .format(exception), exc_info=1) else: logging.debug( 'Subscriber received payload: {}' .format(subscription)) _tag, message, fun = self.parse(subscription) message = self.verify(message) message = self.decode(message) try: result = fun(message) except Exception as exception: logging.error(exception, exc_info=1) return result
module function_definition identifier parameters identifier block expression_statement assignment identifier none expression_statement assignment identifier none try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list except_clause as_pattern 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 keyword_argument identifier integer except_clause as_pattern 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 keyword_argument identifier integer except_clause as_pattern 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 keyword_argument identifier integer except_clause as_pattern 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 keyword_argument identifier integer else_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 assignment pattern_list identifier identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier try_statement block expression_statement assignment identifier call identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier integer return_statement identifier
Receive a subscription from the socket and process it
def walk_tree_and_extract(self, data, target): 'Walk tree of properties and extract identifiers and associated values' if isinstance(data, dict): for key in ['children', 'props',]: self.walk_tree_and_extract(data.get(key, None), target) ident = data.get('id', None) if ident is not None: idVals = target.get(ident, {}) for key, value in data.items(): if key not in ['props', 'options', 'children', 'id']: idVals[key] = value if idVals: target[ident] = idVals if isinstance(data, list): for element in data: self.walk_tree_and_extract(element, target)
module function_definition identifier parameters identifier identifier identifier block expression_statement string string_start string_content string_end if_statement call identifier argument_list identifier identifier block for_statement identifier list string string_start string_content string_end string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier none identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end none if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier dictionary for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement comparison_operator identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block expression_statement assignment subscript identifier identifier identifier if_statement identifier block expression_statement assignment subscript identifier identifier identifier if_statement call identifier argument_list identifier identifier block for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier
Walk tree of properties and extract identifiers and associated values
def _set_range(self, init): if init and (self._scale_factor is not None): return w, h = self._viewbox.size w, h = float(w), float(h) x1, y1, z1 = self._xlim[0], self._ylim[0], self._zlim[0] x2, y2, z2 = self._xlim[1], self._ylim[1], self._zlim[1] rx, ry, rz = (x2 - x1), (y2 - y1), (z2 - z1) if w / h > 1: rx /= w / h ry /= w / h else: rz /= h / w rxs = (rx**2 + ry**2)**0.5 rys = (rx**2 + ry**2 + rz**2)**0.5 self.scale_factor = max(rxs, rys) * 1.04
module function_definition identifier parameters identifier identifier block if_statement boolean_operator identifier parenthesized_expression comparison_operator attribute identifier identifier none block return_statement expression_statement assignment pattern_list identifier identifier attribute attribute identifier identifier identifier expression_statement assignment pattern_list identifier identifier expression_list call identifier argument_list identifier call identifier argument_list identifier expression_statement assignment pattern_list identifier identifier identifier expression_list subscript attribute identifier identifier integer subscript attribute identifier identifier integer subscript attribute identifier identifier integer expression_statement assignment pattern_list identifier identifier identifier expression_list subscript attribute identifier identifier integer subscript attribute identifier identifier integer subscript attribute identifier identifier integer expression_statement assignment pattern_list identifier identifier identifier expression_list parenthesized_expression binary_operator identifier identifier parenthesized_expression binary_operator identifier identifier parenthesized_expression binary_operator identifier identifier if_statement comparison_operator binary_operator identifier identifier integer block expression_statement augmented_assignment identifier binary_operator identifier identifier expression_statement augmented_assignment identifier binary_operator identifier identifier else_clause block expression_statement augmented_assignment identifier binary_operator identifier identifier expression_statement assignment identifier binary_operator parenthesized_expression binary_operator binary_operator identifier integer binary_operator identifier integer float expression_statement assignment identifier binary_operator parenthesized_expression binary_operator binary_operator binary_operator identifier integer binary_operator identifier integer binary_operator identifier integer float expression_statement assignment attribute identifier identifier binary_operator call identifier argument_list identifier identifier float
Reset the camera view using the known limits.
def load_results(result_files, options, run_set_id=None, columns=None, columns_relevant_for_diff=set()): return parallel.map( load_result, result_files, itertools.repeat(options), itertools.repeat(run_set_id), itertools.repeat(columns), itertools.repeat(columns_relevant_for_diff))
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier call identifier argument_list block return_statement call attribute identifier identifier argument_list identifier identifier call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier call attribute identifier identifier argument_list identifier
Version of load_result for multiple input files that will be loaded concurrently.
def _setbitpos(self, pos): if pos < 0: raise ValueError("Bit position cannot be negative.") if pos > self.len: raise ValueError("Cannot seek past the end of the data.") self._pos = pos
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier integer block raise_statement call identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier identifier
Move to absolute postion bit in bitstream.
def dropEvent( self, event ): url = event.mimeData().urls()[0] url_path = nativestring(url.toString()) if ( not url_path.startswith('file:') ): filename = os.path.basename(url_path) temp_path = os.path.join(nativestring(QDir.tempPath()), filename) try: urllib.urlretrieve(url_path, temp_path) except IOError: return self.setFilepath(temp_path) else: self.setFilepath(url_path.replace('file://', ''))
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript call attribute call attribute identifier identifier argument_list identifier argument_list integer expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list if_statement parenthesized_expression not_operator call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call identifier argument_list call attribute identifier identifier argument_list identifier try_statement block expression_statement call attribute identifier identifier argument_list identifier identifier except_clause identifier block return_statement expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end
Handles a drop event.
def intent_path(cls, project, intent): return google.api_core.path_template.expand( 'projects/{project}/agent/intents/{intent}', project=project, intent=intent, )
module function_definition identifier parameters identifier identifier identifier block return_statement call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier identifier
Return a fully-qualified intent string.
def _delete(self, **kwargs): path = self._construct_path_to_item() return self._http.delete(path)
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list return_statement call attribute attribute identifier identifier identifier argument_list identifier
Delete a resource from a remote Transifex server.
def load(name, base_path=None): if '/' in name: return load_location(name, base_path, module=True) return importer.import_symbol(name, base_path)
module function_definition identifier parameters identifier default_parameter identifier none block if_statement comparison_operator string string_start string_content string_end identifier block return_statement call identifier argument_list identifier identifier keyword_argument identifier true return_statement call attribute identifier identifier argument_list identifier identifier
Load a module from a URL or a path
def load(self): private = self.is_private() with open_tls_file(self.file_path, 'r', private=private) as fh: if private: self.x509 = crypto.load_privatekey(self.encoding, fh.read()) else: self.x509 = crypto.load_certificate(self.encoding, fh.read()) return self.x509
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list with_statement with_clause with_item as_pattern call identifier argument_list attribute identifier identifier string string_start string_content string_end keyword_argument identifier identifier as_pattern_target identifier block if_statement identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier call attribute identifier identifier argument_list else_clause block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier call attribute identifier identifier argument_list return_statement attribute identifier identifier
Load from a file and return an x509 object
def _handle_calls(self, service_obj, calls): for call in calls: method = call.get('method') args = call.get('args', []) kwargs = call.get('kwargs', {}) _check_type('args', args, list) _check_type('kwargs', kwargs, dict) if method is None: raise InvalidServiceConfiguration( 'Service call must define a method.' ) new_args = self._replace_scalars_in_args(args) new_kwargs = self._replace_scalars_in_kwargs(kwargs) getattr(service_obj, method)(*new_args, **new_kwargs)
module function_definition identifier parameters identifier identifier identifier block for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end list expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end dictionary expression_statement call identifier argument_list string string_start string_content string_end identifier identifier expression_statement call identifier argument_list string string_start string_content string_end identifier identifier if_statement comparison_operator identifier none 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 expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call call identifier argument_list identifier identifier argument_list list_splat identifier dictionary_splat identifier
Performs method calls on service object
def templates(self): template = lib.EnvGetNextDeftemplate(self._env, ffi.NULL) while template != ffi.NULL: yield Template(self._env, template) template = lib.EnvGetNextDeftemplate(self._env, template)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier while_statement comparison_operator identifier attribute identifier identifier block expression_statement yield call identifier argument_list attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier identifier
Iterate over the defined Templates.
def select_random(ports=None, exclude_ports=None): if ports is None: ports = available_good_ports() if exclude_ports is None: exclude_ports = set() ports.difference_update(set(exclude_ports)) for port in random.sample(ports, min(len(ports), 100)): if not port_is_used(port): return port raise PortForException("Can't select a port")
module function_definition identifier parameters default_parameter identifier none default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier for_statement identifier call attribute identifier identifier argument_list identifier call identifier argument_list call identifier argument_list identifier integer block if_statement not_operator call identifier argument_list identifier block return_statement identifier raise_statement call identifier argument_list string string_start string_content string_end
Returns random unused port number.
def _relay_data(self): "relay any data we have" if self._data: d = self._data self._data = b'' self._sender.dataReceived(d)
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end if_statement attribute identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment attribute identifier identifier string string_start string_end expression_statement call attribute attribute identifier identifier identifier argument_list identifier
relay any data we have
def close(self): if self.connection: logging.info("Closing connection to {}.".format(self.host)) self.connection.close() self.connection = None
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier none
Close internal connection to AMQP if connected.
def post_request(self, request, response): if request.method != api.Method.OPTIONS: response.headers.update(self.request_headers(request)) return response
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator attribute identifier identifier attribute attribute identifier identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list identifier return_statement identifier
Post-request hook to allow CORS headers to responses.
def predict_distance(self, X, batch_size=1, show_progressbar=False): X = self._check_input(X) X_shape = reduce(np.multiply, X.shape[:-1], 1) batched = self._create_batches(X, batch_size, shuffle_data=False) activations = [] activation = self._init_prev(batched) for x in tqdm(batched, disable=not show_progressbar): activation = self.forward(x, prev_activation=activation)[0] activations.append(activation) act = np.asarray(activations, dtype=np.float64).transpose((1, 0, 2)) act = act[:X_shape] return act.reshape(X_shape, self.num_neurons)
module function_definition identifier parameters identifier identifier default_parameter identifier integer default_parameter identifier false block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier subscript attribute identifier identifier slice unary_operator integer integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier keyword_argument identifier false expression_statement assignment identifier list expression_statement assignment identifier call attribute identifier identifier argument_list identifier for_statement identifier call identifier argument_list identifier keyword_argument identifier not_operator identifier block expression_statement assignment identifier subscript call attribute identifier identifier argument_list identifier keyword_argument identifier identifier integer expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier identifier argument_list tuple integer integer integer expression_statement assignment identifier subscript identifier slice identifier return_statement call attribute identifier identifier argument_list identifier attribute identifier identifier
Predict distances to some input data.
def promote(self, lane, svcs=None, meta=None): svcs, meta, lane = self._prep_for_release(lane, svcs=svcs, meta=meta) for svc in svcs: self.changes.append("Promoting: {}.release.future={}".format(svc, self.name)) self.rcs.patch('service', svc, { "release": {"future": self.name}, "statuses": {"future": time.time()}, }) return self
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none block expression_statement assignment pattern_list identifier identifier identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier for_statement identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier dictionary pair string string_start string_content string_end dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end dictionary pair string string_start string_content string_end call attribute identifier identifier argument_list return_statement identifier
promote a build so it is ready for an upper lane
def iter_fasta_qual(fastafile, qualfile, defaultqual=OKQUAL, modify=False): from Bio.SeqIO.QualityIO import PairedFastaQualIterator if not qualfile: qualfile = make_qual(fastafile, score=defaultqual) rec_iter = PairedFastaQualIterator(open(fastafile), open(qualfile)) for rec in rec_iter: yield rec if not modify else modify_qual(rec)
module function_definition identifier parameters identifier identifier default_parameter identifier identifier default_parameter identifier false block import_from_statement dotted_name identifier identifier identifier dotted_name identifier if_statement not_operator identifier block expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier call identifier argument_list identifier for_statement identifier identifier block expression_statement yield conditional_expression identifier not_operator identifier call identifier argument_list identifier
used by trim, emits one SeqRecord with quality values in it
def create_nic(client, target, nic): for network in target.network: if network.name == nic["network_name"]: net = network break else: return None backing = client.create("VirtualEthernetCardNetworkBackingInfo") backing.deviceName = nic["network_name"] backing.network = net connect_info = client.create("VirtualDeviceConnectInfo") connect_info.allowGuestControl = True connect_info.connected = False connect_info.startConnected = True new_nic = client.create(nic["type"]) new_nic.backing = backing new_nic.key = 2 new_nic.unitNumber = 1 new_nic.addressType = "generated" new_nic.connectable = connect_info nic_spec = client.create("VirtualDeviceConfigSpec") nic_spec.device = new_nic nic_spec.fileOperation = None operation = client.create("VirtualDeviceConfigSpecOperation") nic_spec.operation = (operation.add) return nic_spec
module function_definition identifier parameters identifier identifier identifier block for_statement identifier attribute identifier identifier block if_statement comparison_operator attribute identifier identifier subscript identifier string string_start string_content string_end block expression_statement assignment identifier identifier break_statement else_clause block return_statement none expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier subscript identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier true expression_statement assignment attribute identifier identifier false expression_statement assignment attribute identifier identifier true expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier integer expression_statement assignment attribute identifier identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier none expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier parenthesized_expression attribute identifier identifier return_statement identifier
Return a NIC spec
def OnUndo(self, event): statustext = undo.stack().undotext() undo.stack().undo() try: post_command_event(self.grid.main_window, self.grid.ContentChangedMsg) except TypeError: pass self.grid.code_array.result_cache.clear() post_command_event(self.grid.main_window, self.grid.TableChangedMsg, updated_cell=True) self.grid.actions.zoom() self.grid.GetTable().ResetView() shape = self.grid.code_array.shape post_command_event(self.main_window, self.grid.ResizeGridMsg, shape=shape) self.grid.update_entry_line() self.grid.update_attribute_toolbar() post_command_event(self.grid.main_window, self.grid.StatusBarMsg, text=statustext)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list expression_statement call attribute call attribute identifier identifier argument_list identifier argument_list try_statement block expression_statement call identifier argument_list attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier except_clause identifier block pass_statement expression_statement call attribute attribute attribute attribute identifier identifier identifier identifier identifier argument_list expression_statement call identifier argument_list attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier keyword_argument identifier true expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list expression_statement call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list expression_statement assignment identifier attribute attribute attribute identifier identifier identifier identifier expression_statement call identifier argument_list attribute identifier identifier attribute attribute identifier identifier identifier keyword_argument identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call identifier argument_list attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier keyword_argument identifier identifier
Calls the grid undo method
def enqueue_or_delay(self, queue_name=None, priority=None, delayed_until=None, prepend=False, queue_model=None): queue_name = self._get_queue_name(queue_name) fields = {'queued': '1'} if priority is not None: fields['priority'] = priority else: priority = self.priority.hget() in_the_future = delayed_until and delayed_until > datetime.utcnow() if in_the_future: fields['delayed_until'] = str(delayed_until) fields['status'] = STATUSES.DELAYED else: self.delayed_until.delete() fields['status'] = STATUSES.WAITING self.hmset(**fields) if queue_model is None: queue_model = self.queue_model queue = queue_model.get_queue(queue_name, priority) if in_the_future: queue.delay_job(self, delayed_until) else: queue.enqueue_job(self, prepend)
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier false default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end string string_start string_content string_end if_statement comparison_operator identifier none block expression_statement assignment subscript identifier string string_start string_content string_end identifier else_clause block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier boolean_operator identifier comparison_operator identifier call attribute identifier identifier argument_list if_statement identifier block expression_statement assignment subscript identifier string string_start string_content string_end call identifier argument_list identifier expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier expression_statement call attribute identifier identifier argument_list dictionary_splat identifier if_statement comparison_operator identifier none block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier identifier
Will enqueue or delay the job depending of the delayed_until.
def _draw_chars(self, data, to_draw): i = 0 while not self._cursor.atBlockEnd() and i < len(to_draw) and len(to_draw) > 1: self._cursor.deleteChar() i += 1 self._cursor.insertText(to_draw, data.fmt)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier integer while_statement boolean_operator boolean_operator not_operator call attribute attribute identifier identifier identifier argument_list comparison_operator identifier call identifier argument_list identifier comparison_operator call identifier argument_list identifier integer block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement augmented_assignment identifier integer expression_statement call attribute attribute identifier identifier identifier argument_list identifier attribute identifier identifier
Draw the specified charachters using the specified format.
def show_current_metadata(self): LOGGER.debug('Showing layer: ' + self.layer.name()) keywords = KeywordIO(self.layer) content_html = keywords.to_message().to_html() full_html = html_header() + content_html + html_footer() self.metadata_preview_web_view.setHtml(full_html)
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list expression_statement assignment identifier binary_operator binary_operator call identifier argument_list identifier call identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Show metadata of the current selected layer.
def _long_image_slice(in_filepath, out_filepath, slice_size): print 'slicing image: {0}'.format(in_filepath) img = Image.open(in_filepath) width, height = img.size upper = 0 left = 0 slices = int(math.ceil(height / slice_size)) count = 1 for slice in range(slices): if count == slices: lower = height else: lower = int(count * slice_size) bbox = (left, upper, width, lower) working_slice = img.crop(bbox) upper += slice_size new_filepath = _build_sliced_filepath(out_filepath, count) working_slice.save(new_filepath) count += 1
module function_definition identifier parameters identifier identifier identifier block print_statement call attribute string string_start string_content string_end identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment pattern_list identifier identifier attribute identifier identifier expression_statement assignment identifier integer expression_statement assignment identifier integer expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list binary_operator identifier identifier expression_statement assignment identifier integer for_statement identifier call identifier argument_list identifier block if_statement comparison_operator identifier identifier block expression_statement assignment identifier identifier else_clause block expression_statement assignment identifier call identifier argument_list binary_operator identifier identifier expression_statement assignment identifier tuple identifier identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement augmented_assignment identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement augmented_assignment identifier integer
Slice an image into parts slice_size tall.
def divide(self, data_source_factory): data_length = data_source_factory.length() data_interval_length = data_length / self.workers_number() + 1 current_index = 0 self.responses = [] while current_index < data_length: self.responses.append(0) offset = current_index limit = min((data_length - current_index, data_interval_length)) yield data_source_factory.part(limit, offset) current_index += limit
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier binary_operator binary_operator identifier call attribute identifier identifier argument_list integer expression_statement assignment identifier integer expression_statement assignment attribute identifier identifier list while_statement comparison_operator identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list integer expression_statement assignment identifier identifier expression_statement assignment identifier call identifier argument_list tuple binary_operator identifier identifier identifier expression_statement yield call attribute identifier identifier argument_list identifier identifier expression_statement augmented_assignment identifier identifier
Divides the task according to the number of workers.
def _strip_odict(wrapped): @functools.wraps(wrapped) def strip(*args): return salt.utils.json.loads(salt.utils.json.dumps(wrapped(*args))) return strip
module function_definition identifier parameters identifier block decorated_definition decorator call attribute identifier identifier argument_list identifier function_definition identifier parameters list_splat_pattern identifier block return_statement call attribute attribute attribute identifier identifier identifier identifier argument_list call attribute attribute attribute identifier identifier identifier identifier argument_list call identifier argument_list list_splat identifier return_statement identifier
dump to json and load it again, replaces OrderedDicts with regular ones
def negated(input_words, include_nt=True): input_words = [str(w).lower() for w in input_words] neg_words = [] neg_words.extend(NEGATE) for word in neg_words: if word in input_words: return True if include_nt: for word in input_words: if "n't" in word: return True if "least" in input_words: i = input_words.index("least") if i > 0 and input_words[i - 1] != "at": return True return False
module function_definition identifier parameters identifier default_parameter identifier true block expression_statement assignment identifier list_comprehension call attribute call identifier argument_list identifier identifier argument_list for_in_clause identifier identifier expression_statement assignment identifier list expression_statement call attribute identifier identifier argument_list identifier for_statement identifier identifier block if_statement comparison_operator identifier identifier block return_statement true if_statement identifier block for_statement identifier identifier block if_statement comparison_operator string string_start string_content string_end identifier block return_statement true if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement boolean_operator comparison_operator identifier integer comparison_operator subscript identifier binary_operator identifier integer string string_start string_content string_end block return_statement true return_statement false
Determine if input contains negation words
def getkey(self, path, filename=None): scheme, keys = self.getkeys(path, filename=filename) try: key = next(keys) except StopIteration: raise FileNotFoundError("Could not find object for: '%s'" % path) nextKey = None try: nextKey = next(keys) except StopIteration: pass if nextKey: raise ValueError("Found multiple keys for: '%s'" % path) return scheme, key
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier try_statement block expression_statement assignment identifier call identifier argument_list identifier except_clause identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement assignment identifier none try_statement block expression_statement assignment identifier call identifier argument_list identifier except_clause identifier block pass_statement if_statement identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier return_statement expression_list identifier identifier
Get single matching key for a path
def generic_var(self, key, value=None): return self._get_or_set('{0}{1}'.format(self._GENERIC_VAR_KEY_PREFIX, key), value)
module function_definition identifier parameters identifier identifier default_parameter identifier none block return_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier identifier identifier
Stores generic variables in the session prepending it with _GENERIC_VAR_KEY_PREFIX.
def __get_path_to_mecab_config(self): if six.PY2: path_mecab_config_dir = subprocess.check_output(['which', 'mecab-config']) path_mecab_config_dir = path_mecab_config_dir.strip().replace('/mecab-config', '') else: path_mecab_config_dir = subprocess.check_output(['which', 'mecab-config']).decode(self.string_encoding) path_mecab_config_dir = path_mecab_config_dir.strip().replace('/mecab-config', '') logger.info(msg='mecab-config is detected at {}'.format(path_mecab_config_dir)) return path_mecab_config_dir
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list string string_start string_content string_end string string_start string_end else_clause block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list list string string_start string_content string_end string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list string string_start string_content string_end string string_start string_end expression_statement call attribute identifier identifier argument_list keyword_argument identifier call attribute string string_start string_content string_end identifier argument_list identifier return_statement identifier
You get path into mecab-config
def retry_on_bad_auth(func): @wraps(func) def retry_version(self, *args, **kwargs): while True: try: return func(self, *args, **kwargs) except trolly.ResourceUnavailable: sys.stderr.write('bad request (refresh board id)\n') self._board_id = None self.save_key('board_id', None) except trolly.Unauthorised: sys.stderr.write('bad permissions (refresh token)\n') self._client = None self._token = None self.save_key('token', None) return retry_version
module function_definition identifier parameters identifier block decorated_definition decorator call identifier argument_list identifier function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block while_statement true block try_statement block return_statement call identifier argument_list identifier list_splat identifier dictionary_splat identifier except_clause attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content escape_sequence string_end expression_statement assignment attribute identifier identifier none expression_statement call attribute identifier identifier argument_list string string_start string_content string_end none except_clause attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content escape_sequence string_end expression_statement assignment attribute identifier identifier none expression_statement assignment attribute identifier identifier none expression_statement call attribute identifier identifier argument_list string string_start string_content string_end none return_statement identifier
If bad token or board, try again after clearing relevant cache entries
def update_checkpoint(self, checkpoint): if checkpoint is not None and checkpoint != self.checkpoint: self.checkpoint = checkpoint with self.oplog_progress as oplog_prog: oplog_dict = oplog_prog.get_dict() oplog_dict.pop(str(self.oplog), None) oplog_dict[self.replset_name] = checkpoint LOG.debug("OplogThread: oplog checkpoint updated to %s", checkpoint) else: LOG.debug("OplogThread: no checkpoint to update.")
module function_definition identifier parameters identifier identifier block if_statement boolean_operator comparison_operator identifier none comparison_operator identifier attribute identifier identifier block expression_statement assignment attribute identifier identifier identifier with_statement with_clause with_item as_pattern attribute identifier identifier as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list call identifier argument_list attribute identifier identifier none expression_statement assignment subscript identifier attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end
Store the current checkpoint in the oplog progress dictionary.
def getPyCmd(cls): if "win32" in sys.platform: return 'py' elif "linux" in sys.platform: return 'python3' elif 'darwin' in sys.platform: return 'python3' else: cit.err("No python3 command for " + sys.platform)
module function_definition identifier parameters identifier block if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block return_statement string string_start string_content string_end elif_clause comparison_operator string string_start string_content string_end attribute identifier identifier block return_statement string string_start string_content string_end elif_clause comparison_operator string string_start string_content string_end attribute identifier identifier block return_statement string string_start string_content string_end else_clause block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier
get OS's python command
def calculate_rates(base_currency, counter_currency, forward_rate=None, fwd_points=None, spot_reference=None): if base_currency not in DIVISOR_TABLE: divisor = DIVISOR_TABLE.get(counter_currency, DEFAULT_DIVISOR) if forward_rate is None and fwd_points is not None and spot_reference is not None: forward_rate = spot_reference + fwd_points / divisor elif forward_rate is not None and fwd_points is None and spot_reference is not None: fwd_points = (forward_rate - spot_reference) * divisor elif forward_rate is not None and fwd_points is not None and spot_reference is None: spot_reference = forward_rate - fwd_points / divisor rates = {} if forward_rate is not None: rates['forward_rate'] = forward_rate if fwd_points is not None: rates['fwd_points'] = fwd_points if spot_reference is not None: rates['spot_reference'] = spot_reference return rates
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 identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier if_statement boolean_operator boolean_operator comparison_operator identifier none comparison_operator identifier none comparison_operator identifier none block expression_statement assignment identifier binary_operator identifier binary_operator identifier identifier elif_clause boolean_operator boolean_operator comparison_operator identifier none comparison_operator identifier none comparison_operator identifier none block expression_statement assignment identifier binary_operator parenthesized_expression binary_operator identifier identifier identifier elif_clause boolean_operator boolean_operator comparison_operator identifier none comparison_operator identifier none comparison_operator identifier none block expression_statement assignment identifier binary_operator identifier binary_operator identifier identifier expression_statement assignment identifier dictionary if_statement comparison_operator identifier none block expression_statement assignment subscript identifier string string_start string_content string_end identifier if_statement comparison_operator identifier none block expression_statement assignment subscript identifier string string_start string_content string_end identifier if_statement comparison_operator identifier none block expression_statement assignment subscript identifier string string_start string_content string_end identifier return_statement identifier
Calculate rates for Fx Forward based on others.
def import_global(node: Node, key: str, path: Any): node.node_globals[key] = import_path(path)
module function_definition identifier parameters typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier block expression_statement assignment subscript attribute identifier identifier identifier call identifier argument_list identifier
Import passed module, class, function full name and stores it to node's globals
def change_customer_nc_users_quota(sender, structure, user, role, signal, **kwargs): assert signal in (signals.structure_role_granted, signals.structure_role_revoked), \ 'Handler "change_customer_nc_users_quota" has to be used only with structure_role signals' assert sender in (Customer, Project), \ 'Handler "change_customer_nc_users_quota" works only with Project and Customer models' if sender == Customer: customer = structure elif sender == Project: customer = structure.customer customer_users = customer.get_users() customer.set_quota_usage(Customer.Quotas.nc_user_count, customer_users.count())
module function_definition identifier parameters identifier identifier identifier identifier identifier dictionary_splat_pattern identifier block assert_statement comparison_operator identifier tuple attribute identifier identifier attribute identifier identifier string string_start string_content string_end assert_statement comparison_operator identifier tuple identifier identifier string string_start string_content string_end if_statement comparison_operator identifier identifier block expression_statement assignment identifier identifier elif_clause comparison_operator identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list attribute attribute identifier identifier identifier call attribute identifier identifier argument_list
Modify nc_user_count quota usage on structure role grant or revoke
def extend_src_text(self, content, context, text_list, category): prefix = self.prefix + '-' if self.prefix else '' for comment, line, encoding in text_list: content.append( filters.SourceText( textwrap.dedent(comment), "%s (%d)" % (context, line), encoding, prefix + category ) )
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement assignment identifier conditional_expression binary_operator attribute identifier identifier string string_start string_content string_end attribute identifier identifier string string_start string_end for_statement pattern_list identifier identifier identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier binary_operator string string_start string_content string_end tuple identifier identifier identifier binary_operator identifier identifier
Extend the source text list with the gathered text data.
def _frames(traceback): frame = traceback while frame.tb_next: frame = frame.tb_next yield frame.tb_frame return
module function_definition identifier parameters identifier block expression_statement assignment identifier identifier while_statement attribute identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement yield attribute identifier identifier return_statement
Returns generator that iterates over frames in a traceback
def start(host, port=5959, tag='salt/engine/logstash', proto='udp'): if proto == 'tcp': logstashHandler = logstash.TCPLogstashHandler elif proto == 'udp': logstashHandler = logstash.UDPLogstashHandler logstash_logger = logging.getLogger('python-logstash-logger') logstash_logger.setLevel(logging.INFO) logstash_logger.addHandler(logstashHandler(host, port, version=1)) if __opts__.get('id').endswith('_master'): event_bus = salt.utils.event.get_master_event( __opts__, __opts__['sock_dir'], listen=True) else: event_bus = salt.utils.event.get_event( 'minion', transport=__opts__['transport'], opts=__opts__, sock_dir=__opts__['sock_dir'], listen=True) log.debug('Logstash engine started') while True: event = event_bus.get_event() if event: logstash_logger.info(tag, extra=event)
module function_definition identifier parameters identifier default_parameter identifier integer default_parameter identifier string string_start string_content string_end default_parameter identifier string string_start string_content string_end block if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier attribute identifier identifier elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier identifier keyword_argument identifier integer if_statement call attribute call attribute identifier identifier argument_list string string_start string_content string_end identifier argument_list string string_start string_content string_end block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list identifier subscript identifier string string_start string_content string_end keyword_argument identifier true else_clause block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier subscript identifier string string_start string_content string_end keyword_argument identifier true expression_statement call attribute identifier identifier argument_list string string_start string_content string_end while_statement true block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier
Listen to salt events and forward them to logstash
def ensure_shape(core, shape, shape_): core = core.copy() if shape is None: shape = shape_ elif isinstance(shape, int): shape = (shape,) if tuple(shape) == tuple(shape_): return core, shape ones = np.ones(shape, dtype=int) for key, val in core.items(): core[key] = val*ones return core, shape
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier none block expression_statement assignment identifier identifier elif_clause call identifier argument_list identifier identifier block expression_statement assignment identifier tuple identifier if_statement comparison_operator call identifier argument_list identifier call identifier argument_list identifier block return_statement expression_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement assignment subscript identifier identifier binary_operator identifier identifier return_statement expression_list identifier identifier
Ensure shape is correct.
def read_long(self): self.bitcount = self.bits = 0 return unpack('>I', self.input.read(4))[0]
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier assignment attribute identifier identifier integer return_statement subscript call identifier argument_list string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list integer integer
Read an unsigned 32-bit integer
def FileTransfer(*args, **kwargs): if len(args) >= 1: device_type = args[0].device_type else: device_type = kwargs["ssh_conn"].device_type if device_type not in scp_platforms: raise ValueError( "Unsupported SCP device_type: " "currently supported platforms are: {}".format(scp_platforms_str) ) FileTransferClass = FILE_TRANSFER_MAP[device_type] return FileTransferClass(*args, **kwargs)
module function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier attribute subscript identifier integer identifier else_clause block expression_statement assignment identifier attribute subscript identifier string string_start string_content string_end identifier if_statement comparison_operator 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 expression_statement assignment identifier subscript identifier identifier return_statement call identifier argument_list list_splat identifier dictionary_splat identifier
Factory function selects the proper SCP class and creates object based on device_type.
def _validate_edata(self, edata): if edata is None: return True if not (isinstance(edata, dict) or _isiterable(edata)): return False edata = [edata] if isinstance(edata, dict) else edata for edict in edata: if (not isinstance(edict, dict)) or ( isinstance(edict, dict) and ( ("field" not in edict) or ("field" in edict and (not isinstance(edict["field"], str))) or ("value" not in edict) ) ): return False return True
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier none block return_statement true if_statement not_operator parenthesized_expression boolean_operator call identifier argument_list identifier identifier call identifier argument_list identifier block return_statement false expression_statement assignment identifier conditional_expression list identifier call identifier argument_list identifier identifier identifier for_statement identifier identifier block if_statement boolean_operator parenthesized_expression not_operator call identifier argument_list identifier identifier parenthesized_expression boolean_operator call identifier argument_list identifier identifier parenthesized_expression boolean_operator boolean_operator parenthesized_expression comparison_operator string string_start string_content string_end identifier parenthesized_expression boolean_operator comparison_operator string string_start string_content string_end identifier parenthesized_expression not_operator call identifier argument_list subscript identifier string string_start string_content string_end identifier parenthesized_expression comparison_operator string string_start string_content string_end identifier block return_statement false return_statement true
Validate edata argument of raise_exception_if method.
def crud_for_app(app_label, urlprefix=None): if urlprefix is None: urlprefix = app_label + '/' app = apps.get_app_config(app_label) urls = [] for model in app.get_models(): urls += crud_for_model(model, urlprefix) return urls
module function_definition identifier parameters identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier binary_operator identifier string string_start string_content string_end 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 block expression_statement augmented_assignment identifier call identifier argument_list identifier identifier return_statement identifier
Returns list of ``url`` items to CRUD an app.
def request_set_status(self, text: str) -> dict: method_params = {'text': text} response = self.session.send_method_request('status.set', method_params) self.check_for_errors('status.set', method_params, response) return response
module function_definition identifier parameters identifier typed_parameter identifier type identifier type identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier return_statement identifier
Method to set user status
def parse_file_path(cls, file_path): address = None pattern = cls.file_regex.match(file_path) if pattern: address = pattern.group(1) return address
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier none expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list integer return_statement identifier
Parse a file address path without the file specifier
def passwordLogin(self, username): self.challenge = secureRandom(16) self.username = username return {'challenge': self.challenge}
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier call identifier argument_list integer expression_statement assignment attribute identifier identifier identifier return_statement dictionary pair string string_start string_content string_end attribute identifier identifier
Generate a new challenge for the given username.
def field_exists(self, well_x, well_y, field_x, field_y): "Check if field exists ScanFieldArray." return self.field(well_x, well_y, field_x, field_y) != None
module function_definition identifier parameters identifier identifier identifier identifier identifier block expression_statement string string_start string_content string_end return_statement comparison_operator call attribute identifier identifier argument_list identifier identifier identifier identifier none
Check if field exists ScanFieldArray.
def list_database(db): credentials = db.credentials() if credentials: table = Table( db.config['headers'], table_format=db.config['table_format'], colors=db.config['colors'], hidden=db.config['hidden'], hidden_string=db.config['hidden_string'], ) click.echo(table.render(credentials))
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement identifier block expression_statement assignment identifier call identifier argument_list subscript attribute identifier identifier string string_start string_content string_end keyword_argument identifier subscript attribute identifier identifier string string_start string_content string_end keyword_argument identifier subscript attribute identifier identifier string string_start string_content string_end keyword_argument identifier subscript attribute identifier identifier string string_start string_content string_end keyword_argument identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier
Print credential as a table
def load(self, id, *args, **kwargs): self._pre_load(id, *args, **kwargs) response = self._load(id, *args, **kwargs) response = self._post_load(response, *args, **kwargs) return response
module function_definition identifier parameters identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement call attribute identifier identifier argument_list identifier list_splat identifier dictionary_splat identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier list_splat identifier dictionary_splat identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier list_splat identifier dictionary_splat identifier return_statement identifier
loads a remote resource by id