code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def network_create(self, name, **kwargs): nt_ks = self.compute_conn kwargs['label'] = name kwargs = self._sanatize_network_params(kwargs) net = nt_ks.networks.create(**kwargs) return net.__dict__
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list dictionary_splat identifier return_statement attribute identifier identifier
Create extra private network
def do_status(self, line): print('{} {}'.format(bold('Pyrene version'), green(get_version()))) pip_conf = os.path.expanduser('~/.pip/pip.conf') if os.path.exists(pip_conf): conf = read_file(pip_conf) repo = self._get_repo_for_pip_conf(conf) if repo: print( '{} is configured for repository "{}"' .format(bold(pip_conf), green(repo.name)) ) else: print( '{} exists, but is a {}' .format(bold(pip_conf), red('custom configuration')) ) else: print('{} {}'.format(bold(pip_conf), red('does not exists'))) if os.path.exists(self.pypirc): template = green('exists') else: template = red('does not exists') template = '{} ' + template print(template.format(bold(self.pypirc)))
module function_definition identifier parameters identifier identifier block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list call identifier argument_list string string_start string_content string_end call identifier argument_list call identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier call identifier argument_list attribute identifier identifier else_clause block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier call identifier argument_list string string_start string_content string_end else_clause block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier call identifier argument_list string string_start string_content string_end if_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier block expression_statement assignment identifier call identifier argument_list string string_start string_content string_end else_clause block expression_statement assignment identifier 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 call identifier argument_list call attribute identifier identifier argument_list call identifier argument_list attribute identifier identifier
Show python packaging configuration status
def _expand(self, line: str) -> str: tmp_aliases = list(self.aliases.keys()) keep_expanding = bool(tmp_aliases) while keep_expanding: for cur_alias in tmp_aliases: keep_expanding = False match = self._command_pattern.search(line) if match: command = match.group(1) if command and command == cur_alias: line = self.aliases[cur_alias] + match.group(2) + line[match.end(2):] tmp_aliases.remove(cur_alias) keep_expanding = bool(tmp_aliases) break for (shortcut, expansion) in self.shortcuts: if line.startswith(shortcut): shortcut_len = len(shortcut) if len(line) == shortcut_len or line[shortcut_len] != ' ': expansion += ' ' line = line.replace(shortcut, expansion, 1) break return line
module function_definition identifier parameters identifier typed_parameter identifier type identifier type identifier block expression_statement assignment identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call identifier argument_list identifier while_statement identifier block for_statement identifier identifier block expression_statement assignment identifier false 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 if_statement boolean_operator identifier comparison_operator identifier identifier block expression_statement assignment identifier binary_operator binary_operator subscript attribute identifier identifier identifier call attribute identifier identifier argument_list integer subscript identifier slice call attribute identifier identifier argument_list integer expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier break_statement for_statement tuple_pattern identifier identifier attribute identifier identifier block if_statement call attribute identifier identifier argument_list identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement boolean_operator comparison_operator call identifier argument_list identifier identifier comparison_operator subscript identifier identifier string string_start string_content string_end block expression_statement augmented_assignment identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier integer break_statement return_statement identifier
Expand shortcuts and aliases
def _setable_get_(name, self): "Used to raise an exception for attributes unable to be evaluated yet." raise AttributeError( "'{typename}' object has no attribute '{name}'".format( typename=type(self).__name__, name=name ) )
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier attribute call identifier argument_list identifier identifier keyword_argument identifier identifier
Used to raise an exception for attributes unable to be evaluated yet.
def record_leaving(self, time, code, frame_key, parent_stats): try: stats = parent_stats.get_child(code) time_entered = self._times_entered.pop((code, frame_key)) except KeyError: return time_elapsed = time - time_entered stats.deep_time += max(0, time_elapsed)
module function_definition identifier parameters identifier identifier identifier identifier identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list tuple identifier identifier except_clause identifier block return_statement expression_statement assignment identifier binary_operator identifier identifier expression_statement augmented_assignment attribute identifier identifier call identifier argument_list integer identifier
Left from a function call.
def download_content(**args): args = validate_args(**args) if not args['directory']: args['directory'] = args['query'].replace(' ', '-') print("Downloading {0} {1} files on topic {2} from {3} and saving to directory: {4}" .format(args['limit'], args['file_type'], args['query'], args['website'], args['directory'])) links = search(args['query'], args['engine'], args['website'], args['file_type'], args['limit']) if args['parallel']: download_parallel(links, args['directory'], args['min_file_size'], args['max_file_size'], args['no_redirects']) else: download_series(links, args['directory'], args['min_file_size'], args['max_file_size'], args['no_redirects'])
module function_definition identifier parameters dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list dictionary_splat identifier if_statement not_operator subscript identifier string string_start string_content string_end block expression_statement assignment subscript identifier string string_start string_content string_end call attribute subscript identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end if_statement subscript identifier string string_start string_content string_end block expression_statement call identifier argument_list identifier subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end else_clause block expression_statement call identifier argument_list identifier subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end
main function to fetch links and download them
def _get_existing_report(self, mask, report): for existing_report in self._reports: if existing_report['namespace'] == report['namespace']: if mask == existing_report['queryMask']: return existing_report return None
module function_definition identifier parameters identifier identifier identifier block for_statement identifier attribute identifier identifier block if_statement comparison_operator subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end block if_statement comparison_operator identifier subscript identifier string string_start string_content string_end block return_statement identifier return_statement none
Returns the aggregated report that matches report
def expand_folder(files): expfiles = [] for file in files: if os.path.isdir(file): for dirpath, dirnames, filenames in os.walk(file): for filename in filenames: expfiles.append(os.path.join(dirpath, filename)) else: expfiles.append(file) for path in expfiles: if not os.path.exists(path): sys.stderr.write('%s: No such file or directory\n' % path) return expfiles
module function_definition identifier parameters identifier block expression_statement assignment identifier list for_statement identifier identifier block if_statement call attribute attribute identifier identifier identifier argument_list identifier block for_statement pattern_list identifier identifier identifier call attribute identifier identifier argument_list identifier block for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list identifier for_statement identifier identifier block if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content escape_sequence string_end identifier return_statement identifier
Return a clone of file list files where all directories are recursively replaced with their contents.
def _from_dict(cls, _dict): args = {} if 'tokens' in _dict: args['tokens'] = [ TokenResult._from_dict(x) for x in (_dict.get('tokens')) ] if 'sentences' in _dict: args['sentences'] = [ SentenceResult._from_dict(x) for x in (_dict.get('sentences')) ] return cls(**args)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier parenthesized_expression call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier parenthesized_expression call attribute identifier identifier argument_list string string_start string_content string_end return_statement call identifier argument_list dictionary_splat identifier
Initialize a SyntaxResult object from a json dictionary.
def layer_pre_save(instance, *args, **kwargs): is_valid = True if not instance.service.type == 'Hypermap:WorldMap': if not instance.service.is_valid: is_valid = False LOGGER.debug('Layer with id %s is marked invalid because its service is invalid' % instance.id) if instance.bbox_x0 > -2 and instance.bbox_x1 < 2 and instance.bbox_y0 > -2 and instance.bbox_y1 < 2: is_valid = False LOGGER.debug( 'Layer with id %s is marked invalid because its extent is within (-2, -2, +2, +2)' % instance.id ) instance.is_valid = is_valid
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier true if_statement not_operator comparison_operator attribute attribute identifier identifier identifier string string_start string_content string_end block if_statement not_operator attribute attribute identifier identifier identifier block expression_statement assignment identifier false expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier if_statement boolean_operator boolean_operator boolean_operator comparison_operator attribute identifier identifier unary_operator integer comparison_operator attribute identifier identifier integer comparison_operator attribute identifier identifier unary_operator integer comparison_operator attribute identifier identifier integer block expression_statement assignment identifier false expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier expression_statement assignment attribute identifier identifier identifier
Used to check layer validity.
def mysql_to_dict(data, key): ret = {} headers = [''] for line in data: if not line: continue if line.startswith('+'): continue comps = line.split('|') for comp in range(len(comps)): comps[comp] = comps[comp].strip() if len(headers) > 1: index = len(headers) - 1 row = {} for field in range(index): if field < 1: continue else: row[headers[field]] = salt.utils.stringutils.to_num(comps[field]) ret[row[key]] = row else: headers = comps return ret
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary expression_statement assignment identifier list string string_start string_end for_statement identifier identifier block if_statement not_operator identifier block continue_statement if_statement call attribute identifier identifier argument_list string string_start string_content string_end block continue_statement expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end for_statement identifier call identifier argument_list call identifier argument_list identifier block expression_statement assignment subscript identifier identifier call attribute subscript identifier identifier identifier argument_list if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier binary_operator call identifier argument_list identifier integer expression_statement assignment identifier dictionary for_statement identifier call identifier argument_list identifier block if_statement comparison_operator identifier integer block continue_statement else_clause block expression_statement assignment subscript identifier subscript identifier identifier call attribute attribute attribute identifier identifier identifier identifier argument_list subscript identifier identifier expression_statement assignment subscript identifier subscript identifier identifier identifier else_clause block expression_statement assignment identifier identifier return_statement identifier
Convert MySQL-style output to a python dictionary
def nested(self, format_callback=None): seen = set() roots = [] for root in self.edges.get(None, ()): roots.extend(self._nested(root, seen, format_callback)) return roots
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier list for_statement identifier call attribute attribute identifier identifier identifier argument_list none tuple block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier identifier identifier return_statement identifier
Return the graph as a nested list.
def human_size(bytes, units=[' bytes','KB','MB','GB','TB', 'PB', 'EB']): return str(bytes) + units[0] if bytes < 1024 else human_size(bytes>>10, units[1:])
module function_definition identifier parameters identifier default_parameter identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block return_statement conditional_expression binary_operator call identifier argument_list identifier subscript identifier integer comparison_operator identifier integer call identifier argument_list binary_operator identifier integer subscript identifier slice integer
Returns a human readable string reprentation of bytes
def _listen(self, uuid=None, session=None): if self.url is None: raise Exception("NURESTPushCenter needs to have a valid URL. please use setURL: before starting it.") events_url = "%s/events" % self.url if uuid: events_url = "%s?uuid=%s" % (events_url, uuid) request = NURESTRequest(method='GET', url=events_url) connection = NURESTConnection(request=request, async=True, callback=self._did_receive_event, root_object=self._root_object) if self._timeout: if int(time()) - self._start_time >= self._timeout: pushcenter_logger.debug("[NURESTPushCenter] Timeout (timeout=%ss)." % self._timeout) return else: connection.timeout = self._timeout pushcenter_logger.info('Bambou Sending >>>>>>\n%s %s' % (request.method, request.url)) connection.start()
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none block if_statement comparison_operator attribute identifier identifier none block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier binary_operator string string_start string_content string_end attribute identifier identifier if_statement identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end tuple identifier identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier true keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier if_statement attribute identifier identifier block if_statement comparison_operator binary_operator call identifier argument_list call identifier argument_list attribute identifier identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier return_statement else_clause block expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content escape_sequence string_end tuple attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list
Listen a connection uuid
def tag_builder(parser, token, cls, flow_type): tokens = token.split_contents() tokens_num = len(tokens) if tokens_num == 1 or (tokens_num == 3 and tokens[1] == 'for'): flow_name = None if tokens_num == 3: flow_name = tokens[2] return cls(flow_name) else: raise template.TemplateSyntaxError( '"sitegate_%(type)s_form" tag requires zero or two arguments. ' 'E.g. {%% sitegate_%(type)s_form %%} or ' '{%% sitegate_%(type)s_form for ClassicSignup %%}.' % {'type': flow_type})
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list identifier if_statement boolean_operator comparison_operator identifier integer parenthesized_expression boolean_operator comparison_operator identifier integer comparison_operator subscript identifier integer string string_start string_content string_end block expression_statement assignment identifier none if_statement comparison_operator identifier integer block expression_statement assignment identifier subscript identifier integer return_statement call identifier argument_list identifier else_clause block raise_statement call attribute identifier identifier argument_list binary_operator concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end dictionary pair string string_start string_content string_end identifier
Helper function handling flow form tags.
def DisplayGetter(accessor, *args, **kwargs): short_description = get_pretty_name(accessor) accessor = 'get_%s_display' % accessor getter = Getter(accessor, *args, **kwargs) getter.short_description = short_description return getter
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier binary_operator string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list identifier list_splat identifier dictionary_splat identifier expression_statement assignment attribute identifier identifier identifier return_statement identifier
Returns a Getter that gets the display name for a model field with choices.
def commit(message=COMMON_COMMIT_MESSAGE, capture=True): env.warn_only = True local(u'git commit -am"{}"'.format(message))
module function_definition identifier parameters default_parameter identifier identifier default_parameter identifier true block expression_statement assignment attribute identifier identifier true expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier
git commit with common commit message when omit.
def main(): args = parser.parse_args() try: function = args.func except AttributeError: parser.print_usage() parser.exit(1) function(vars(args))
module function_definition identifier parameters block expression_statement assignment identifier call attribute identifier identifier argument_list try_statement block expression_statement assignment identifier attribute identifier identifier except_clause identifier block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list integer expression_statement call identifier argument_list call identifier argument_list identifier
Parse the args and call whatever function was selected
def _get_base_class_names(frame): co, lasti = frame.f_code, frame.f_lasti code = co.co_code extends = [] for (op, oparg) in op_stream(code, lasti): if op in dis.hasconst: if type(co.co_consts[oparg]) == str: extends = [] elif op in dis.hasname: if dis.opname[op] == 'LOAD_NAME': extends.append(('name', co.co_names[oparg])) if dis.opname[op] == 'LOAD_ATTR': extends.append(('attr', co.co_names[oparg])) if dis.opname[op] == 'LOAD_GLOBAL': extends.append(('name', co.co_names[oparg])) items = [] previous_item = [] for t, s in extends: if t == 'name': if previous_item: items.append(previous_item) previous_item = [s] else: previous_item += [s] if previous_item: items.append(previous_item) return items
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier expression_list attribute identifier identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier list for_statement tuple_pattern identifier identifier call identifier argument_list identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block if_statement comparison_operator call identifier argument_list subscript attribute identifier identifier identifier identifier block expression_statement assignment identifier list elif_clause comparison_operator identifier attribute identifier identifier block if_statement comparison_operator subscript attribute identifier identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list tuple string string_start string_content string_end subscript attribute identifier identifier identifier if_statement comparison_operator subscript attribute identifier identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list tuple string string_start string_content string_end subscript attribute identifier identifier identifier if_statement comparison_operator subscript attribute identifier identifier identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list tuple string string_start string_content string_end subscript attribute identifier identifier identifier expression_statement assignment identifier list expression_statement assignment identifier list for_statement pattern_list identifier identifier identifier block if_statement comparison_operator identifier string string_start string_content string_end block if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier list identifier else_clause block expression_statement augmented_assignment identifier list identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Get baseclass names from the code object
def check_if_needs_inversion(tomodir): required_files = ( 'grid' + os.sep + 'elem.dat', 'grid' + os.sep + 'elec.dat', 'exe' + os.sep + 'crtomo.cfg', ) needs_inversion = True for filename in required_files: if not os.path.isfile(tomodir + os.sep + filename): needs_inversion = False if not os.path.isfile(tomodir + os.sep + 'mod' + os.sep + 'volt.dat'): if not check_if_needs_modeling(tomodir): print('no volt.dat and no modeling possible') needs_inversion = False inv_ctr_file = tomodir + os.sep + 'inv' + os.sep + 'inv.ctr' if os.path.isfile(inv_ctr_file): inv_lines = open(inv_ctr_file, 'r').readlines() print('inv_lines', inv_lines[-1]) if inv_lines[-1].startswith('***finished***'): needs_inversion = False return needs_inversion
module function_definition identifier parameters identifier block expression_statement assignment identifier tuple binary_operator binary_operator string string_start string_content string_end attribute identifier identifier string string_start string_content string_end binary_operator binary_operator string string_start string_content string_end attribute identifier identifier string string_start string_content string_end binary_operator binary_operator string string_start string_content string_end attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier true for_statement identifier identifier block if_statement not_operator call attribute attribute identifier identifier identifier argument_list binary_operator binary_operator identifier attribute identifier identifier identifier block expression_statement assignment identifier false if_statement not_operator call attribute attribute identifier identifier identifier argument_list binary_operator binary_operator binary_operator binary_operator identifier attribute identifier identifier string string_start string_content string_end attribute identifier identifier string string_start string_content string_end block if_statement not_operator call identifier argument_list identifier block expression_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier false expression_statement assignment identifier binary_operator binary_operator binary_operator binary_operator identifier attribute identifier identifier string string_start string_content string_end attribute identifier identifier string string_start string_content string_end if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement assignment identifier call attribute call identifier argument_list identifier string string_start string_content string_end identifier argument_list expression_statement call identifier argument_list string string_start string_content string_end subscript identifier unary_operator integer if_statement call attribute subscript identifier unary_operator integer identifier argument_list string string_start string_content string_end block expression_statement assignment identifier false return_statement identifier
check of we need to run CRTomo in a given tomodir
def make_arg(key, annotation=None): arg = ast.arg(key, annotation) arg.lineno, arg.col_offset = 0, 0 return arg
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment pattern_list attribute identifier identifier attribute identifier identifier expression_list integer integer return_statement identifier
Make an ast function argument.
def connect(self, sock): def cbwrap(*args, **kwargs): self.callback(self.response_type, *args, **kwargs) self.sock = sock self.sock.subscribe(self.channel) self.sock.onchannel(self.channel, cbwrap)
module function_definition identifier parameters identifier identifier block function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier list_splat identifier dictionary_splat identifier expression_statement assignment attribute identifier identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier
Attach a given socket to a channel
def _number_of_rows(self, start=0, count=100, **kwargs): first = str(start) last = str(start + count) string_format = ':'.join([first, last]) return string_format
module function_definition identifier parameters identifier default_parameter identifier integer default_parameter identifier integer dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list binary_operator identifier identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list list identifier identifier return_statement identifier
Internal method to format the number of rows the EPA API returns.
def read(path): data = None with open(path, 'r') as f: data = f.read() f.close() return data
module function_definition identifier parameters identifier block expression_statement assignment identifier none with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list return_statement identifier
Reads a file located at the given path.
def directory_values_generator(self, key): directory = self.directory(key) for key in directory: yield self.get(Key(key))
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier for_statement identifier identifier block expression_statement yield call attribute identifier identifier argument_list call identifier argument_list identifier
Retrieve directory values for given key.
def show_graphs(self): elements = itertools.chain.from_iterable( ([graph] for graph in self.visible_graphs.values())) self.graph_place_holder.original_widget = urwid.Pile(elements)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list generator_expression list identifier for_in_clause identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute attribute identifier identifier identifier call attribute identifier identifier argument_list identifier
Show a pile of the graph selected for dislpay
def update(self): if self._is_ignored or "tags" not in self._tag_group_dict: return for i in range(len(self._tag_group_dict["tags"])): tag_dict = self._tag_group_dict["tags"][i] for tag in self._tags: if tag.name == tag_dict["common.ALLTYPES_NAME"]: self._tag_group_dict["tags"][i] = tag.as_dict() break for i in range(len(self._sub_groups)): sub_group = self._sub_groups[i] sub_group.update() self._tag_group_dict["tag_groups"][i] = sub_group.as_dict()
module function_definition identifier parameters identifier block if_statement boolean_operator attribute identifier identifier comparison_operator string string_start string_content string_end attribute identifier identifier block return_statement for_statement identifier call identifier argument_list call identifier argument_list subscript attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier subscript subscript attribute identifier identifier string string_start string_content string_end identifier 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 subscript subscript attribute identifier identifier string string_start string_content string_end identifier call attribute identifier identifier argument_list break_statement for_statement identifier call identifier argument_list call identifier argument_list attribute identifier identifier block expression_statement assignment identifier subscript attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement assignment subscript subscript attribute identifier identifier string string_start string_content string_end identifier call attribute identifier identifier argument_list
Updates the dictionary of the tag group
def _startProcess(self): connectedDeferred = defer.Deferred() processProtocol = RelayProcessProtocol(connectedDeferred) self.inductor.execute(processProtocol, *self.inductorArgs) return connectedDeferred
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier list_splat attribute identifier identifier return_statement identifier
Use the inductor to start the process we want to relay data from.
def find_user_by_username(self, username): return self.db_adapter.ifind_first_object(self.UserClass, username=username)
module function_definition identifier parameters identifier identifier block return_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier keyword_argument identifier identifier
Find a User object by username.
def create_build_context(self, variant, build_type, build_path): request = variant.get_requires(build_requires=True, private_build_requires=True) req_strs = map(str, request) quoted_req_strs = map(quote, req_strs) self._print("Resolving build environment: %s", ' '.join(quoted_req_strs)) if build_type == BuildType.local: packages_path = self.package.config.packages_path else: packages_path = self.package.config.nonlocal_packages_path if self.package.config.is_overridden("package_filter"): from rez.package_filter import PackageFilterList data = self.package.config.package_filter package_filter = PackageFilterList.from_pod(data) else: package_filter = None context = ResolvedContext(request, package_paths=packages_path, package_filter=package_filter, building=True) if self.verbose: context.print_info() rxt_filepath = os.path.join(build_path, "build.rxt") context.save(rxt_filepath) if context.status != ResolverStatus.solved: raise BuildContextResolveError(context) return context, rxt_filepath
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier true keyword_argument identifier true expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list identifier if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier attribute attribute attribute identifier identifier identifier identifier else_clause block expression_statement assignment identifier attribute attribute attribute identifier identifier identifier identifier if_statement call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end block import_from_statement dotted_name identifier identifier dotted_name identifier expression_statement assignment identifier attribute attribute attribute identifier identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier else_clause block expression_statement assignment identifier none expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier true if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier if_statement comparison_operator attribute identifier identifier attribute identifier identifier block raise_statement call identifier argument_list identifier return_statement expression_list identifier identifier
Create a context to build the variant within.
def check_scalar(self, scalar_dict): table = {k: np.array([v]) for k, v in scalar_dict.items()} return self.mask(table)[0]
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary_comprehension pair identifier call attribute identifier identifier argument_list list identifier for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list return_statement subscript call attribute identifier identifier argument_list identifier integer
check if `scalar_dict` satisfy query
async def logout(self, request): if "Authorization" not in request.headers: msg = "Auth header is not present, can not destroy token" raise JsonValidaitonError(msg) response = json_response() await forget(request, response) return response
module function_definition identifier parameters identifier identifier block if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block expression_statement assignment identifier string string_start string_content string_end raise_statement call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list expression_statement await call identifier argument_list identifier identifier return_statement identifier
Simple handler for logout
def _depth_im_callback(self, msg): try: self._cur_depth_im = DepthImage(self._bridge.imgmsg_to_cv2(msg) / 1000.0, frame=self._frame) except: self._cur_depth_im = None
module function_definition identifier parameters identifier identifier block try_statement block expression_statement assignment attribute identifier identifier call identifier argument_list binary_operator call attribute attribute identifier identifier identifier argument_list identifier float keyword_argument identifier attribute identifier identifier except_clause block expression_statement assignment attribute identifier identifier none
Callback for handling depth images.
def _find_usage_vpcs(self): vpcs = self.conn.describe_vpcs() self.limits['VPCs']._add_current_usage( len(vpcs['Vpcs']), aws_type='AWS::EC2::VPC' )
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute subscript attribute identifier identifier string string_start string_content string_end identifier argument_list call identifier argument_list subscript identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end
find usage for VPCs
def _router_numbers(self): return tuple(up for up in self._up2down.keys() if up in self._up2down.values())
module function_definition identifier parameters identifier block return_statement call identifier generator_expression identifier for_in_clause identifier call attribute attribute identifier identifier identifier argument_list if_clause comparison_operator identifier call attribute attribute identifier identifier identifier argument_list
A tuple of the numbers of all "routing" basins.
def replace(self, new_node): cur_node = self.cur_node nodestack = self.nodestack cur = nodestack.pop() prev = nodestack[-1] index = prev[-1] - 1 oldnode, name = prev[-2][index] assert cur[0] is cur_node is oldnode, (cur[0], cur_node, prev[-2], index) parent = prev[0] if isinstance(parent, list): parent[index] = new_node else: setattr(parent, name, new_node)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier subscript identifier unary_operator integer expression_statement assignment identifier binary_operator subscript identifier unary_operator integer integer expression_statement assignment pattern_list identifier identifier subscript subscript identifier unary_operator integer identifier assert_statement comparison_operator subscript identifier integer identifier identifier tuple subscript identifier integer identifier subscript identifier unary_operator integer identifier expression_statement assignment identifier subscript identifier integer if_statement call identifier argument_list identifier identifier block expression_statement assignment subscript identifier identifier identifier else_clause block expression_statement call identifier argument_list identifier identifier identifier
Replace a node after first checking integrity of node stack.
def _save_sensitivities(self, directory): print('saving sensitivities') digits = int(np.ceil(np.log10(self.configs.configs.shape[0]))) for i in range(0, self.configs.configs.shape[0]): sens_data, meta_data = self.get_sensitivity(i) filename_raw = 'sens{0:0' + '{0}'.format(digits) + '}.dat' filename = directory + os.sep + filename_raw.format(i + 1) grid_xz = self.grid.get_element_centroids() all_data = np.vstack(( grid_xz[:, 0], grid_xz[:, 0], sens_data[0], sens_data[1], )).T with open(filename, 'wb') as fid: fid.write(bytes( '{0} {1}\n'.format(meta_data[0], meta_data[1]), 'utf-8' )) np.savetxt(fid, all_data)
module function_definition identifier parameters identifier identifier block expression_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list subscript attribute attribute attribute identifier identifier identifier identifier integer for_statement identifier call identifier argument_list integer subscript attribute attribute attribute identifier identifier identifier identifier integer block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier binary_operator binary_operator string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier binary_operator binary_operator identifier attribute identifier identifier call attribute identifier identifier argument_list binary_operator identifier integer expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier attribute call attribute identifier identifier argument_list tuple subscript identifier slice integer subscript identifier slice integer subscript identifier integer subscript identifier integer identifier with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list subscript identifier integer subscript identifier integer string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier identifier
save sensitivities to a directory
def probe(self, ipaddr=None): if ipaddr is None: ipaddr = self._broadcast_addr cmd = {"payloadtype": PayloadType.GET, "target": ipaddr} self._send_command(cmd)
module function_definition identifier parameters identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier
Probe given address for bulb.
def serialize_compound(self, tag): separator, fmt = self.comma, '{{{}}}' with self.depth(): if self.should_expand(tag): separator, fmt = self.expand(separator, fmt) return fmt.format(separator.join( f'{self.stringify_compound_key(key)}{self.colon}{self.serialize(value)}' for key, value in tag.items() ))
module function_definition identifier parameters identifier identifier block expression_statement assignment pattern_list identifier identifier expression_list attribute identifier identifier string string_start string_content string_end with_statement with_clause with_item call attribute identifier identifier argument_list block if_statement call attribute identifier identifier argument_list identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier identifier return_statement call attribute identifier identifier argument_list call attribute identifier identifier generator_expression string string_start interpolation call attribute identifier identifier argument_list identifier interpolation attribute identifier identifier interpolation call attribute identifier identifier argument_list identifier string_end for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list
Return the literal representation of a compound tag.
def projectname(self): if self._projectname is None: exps = self.config.experiments if self._experiment is not None and self._experiment in exps: return exps[self._experiment]['project'] try: self._projectname = list(self.config.projects.keys())[-1] except IndexError: raise ValueError( "No experiment has yet been created! Please run setup " "before.") return self._projectname
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier attribute attribute identifier identifier identifier if_statement boolean_operator comparison_operator attribute identifier identifier none comparison_operator attribute identifier identifier identifier block return_statement subscript subscript identifier attribute identifier identifier string string_start string_content string_end try_statement block expression_statement assignment attribute identifier identifier subscript call identifier argument_list call attribute attribute attribute identifier identifier identifier identifier argument_list unary_operator integer except_clause identifier block raise_statement call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end return_statement attribute identifier identifier
The name of the project that is currently processed
def parse_nested( bels: list, char_locs: CharLocs, parsed: Parsed, errors: Errors ) -> Tuple[Parsed, Errors]: for sp in char_locs[ "nested_parens" ]: ep, level = char_locs["nested_parens"][sp] if ep == -1: ep = len(bels) + 1 parsed[(sp, ep)] = {"type": "Nested", "span": (sp, ep)} return parsed, errors
module function_definition identifier parameters typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier type generic_type identifier type_parameter type identifier type identifier block for_statement identifier subscript identifier string string_start string_content string_end block expression_statement assignment pattern_list identifier identifier subscript subscript identifier string string_start string_content string_end identifier if_statement comparison_operator identifier unary_operator integer block expression_statement assignment identifier binary_operator call identifier argument_list identifier integer expression_statement assignment subscript identifier tuple identifier 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 tuple identifier identifier return_statement expression_list identifier identifier
Parse nested BEL object
def WindowsSdkVersion(self): if self.vc_ver <= 9.0: return ('7.0', '6.1', '6.0a') elif self.vc_ver == 10.0: return ('7.1', '7.0a') elif self.vc_ver == 11.0: return ('8.0', '8.0a') elif self.vc_ver == 12.0: return ('8.1', '8.1a') elif self.vc_ver >= 14.0: return ('10.0', '8.1')
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier float block return_statement tuple string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end elif_clause comparison_operator attribute identifier identifier float block return_statement tuple string string_start string_content string_end string string_start string_content string_end elif_clause comparison_operator attribute identifier identifier float block return_statement tuple string string_start string_content string_end string string_start string_content string_end elif_clause comparison_operator attribute identifier identifier float block return_statement tuple string string_start string_content string_end string string_start string_content string_end elif_clause comparison_operator attribute identifier identifier float block return_statement tuple string string_start string_content string_end string string_start string_content string_end
Microsoft Windows SDK versions for specified MSVC++ version.
def generate_header_validator(headers, context, **kwargs): validators = ValidationDict() for header_definition in headers: header_processor = generate_value_processor( context=context, **header_definition ) header_validator = generate_object_validator( field_validators=construct_header_validators(header_definition, context=context), ) validators.add_property_validator( header_definition['name'], chain_reduce_partial( header_processor, header_validator, ), ) return generate_object_validator(field_validators=validators)
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list for_statement identifier identifier block expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier dictionary_splat identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier call identifier argument_list identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end call identifier argument_list identifier identifier return_statement call identifier argument_list keyword_argument identifier identifier
Generates a validation function that will validate a dictionary of headers.
def listen(self, listener): for message in listener.listen(): try: data = json.loads(message['data']) if data['event'] in ('canceled', 'lock_lost', 'put'): self.kill(data['jid']) except: logger.exception('Pubsub error')
module function_definition identifier parameters identifier identifier block for_statement identifier call attribute identifier identifier argument_list block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end if_statement comparison_operator subscript identifier string string_start string_content string_end tuple string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end except_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end
Listen for events that affect our ownership of a job
def simple_locking(lock_id, expiration=None): def inner_decorator(function): def wrapper(*args, **kwargs): try: lock = Lock.acquire_lock(lock_id, expiration) except LockError: pass else: logger.debug('acquired lock: %s' % lock_id) try: return function(*args, **kwargs) except: raise finally: lock.release() return wraps(function)(wrapper) return inner_decorator
module function_definition identifier parameters identifier default_parameter identifier none block function_definition identifier parameters identifier block function_definition identifier parameters list_splat_pattern identifier dictionary_splat_pattern identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier except_clause identifier block pass_statement else_clause block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier try_statement block return_statement call identifier argument_list list_splat identifier dictionary_splat identifier except_clause block raise_statement finally_clause block expression_statement call attribute identifier identifier argument_list return_statement call call identifier argument_list identifier argument_list identifier return_statement identifier
A decorator that wraps a function in a single lock getting algorithm
def explode(prefix: str): def _app(i, e=None): if i is not None: return {k: v for (k, v) in iter_fields(i)}, None return i, e def iter_fields(event_field: Union[dict, list]): if type(event_field) is dict: for key, val in event_field.items(): yield (key, val) elif type(event_field) is list: for i, value in enumerate(event_field): for key, val in value.items(): if not i == 0: yield ("{}_{}".format(key, i), val) else: yield (key, val) return compose(_app, add_column_prefix(prefix))
module function_definition identifier parameters typed_parameter identifier type identifier block function_definition identifier parameters identifier default_parameter identifier none block if_statement comparison_operator identifier none block return_statement expression_list dictionary_comprehension pair identifier identifier for_in_clause tuple_pattern identifier identifier call identifier argument_list identifier none return_statement expression_list identifier identifier function_definition identifier parameters typed_parameter identifier type generic_type identifier type_parameter type identifier type identifier block if_statement comparison_operator call identifier argument_list identifier identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement yield tuple identifier identifier elif_clause comparison_operator call identifier argument_list identifier identifier block for_statement pattern_list identifier identifier call identifier argument_list identifier block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement not_operator comparison_operator identifier integer block expression_statement yield tuple call attribute string string_start string_content string_end identifier argument_list identifier identifier identifier else_clause block expression_statement yield tuple identifier identifier return_statement call identifier argument_list identifier call identifier argument_list identifier
given an array of objects de-normalized into fields
def parse_version(str_): v = re.findall(r"\d+.\d+.\d+", str_) if v: return v[0] else: print("cannot parse string {}".format(str_)) raise KeyError
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement identifier block return_statement subscript identifier integer else_clause block expression_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier raise_statement identifier
Parses the program's version from a python variable declaration.
def drop(self, ex): "helper for apply_sql in DropX case" if ex.name not in self: if ex.ifexists: return raise KeyError(ex.name) table_ = self[ex.name] parent = table_.parent_table if table_.child_tables: if not ex.cascade: raise table.IntegrityError('delete_parent_without_cascade',ex.name) self.cascade_delete(ex.name) else: del self[ex.name] if parent: parent.child_tables.remove(table_)
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end if_statement comparison_operator attribute identifier identifier identifier block if_statement attribute identifier identifier block return_statement raise_statement call identifier argument_list attribute identifier identifier expression_statement assignment identifier subscript identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier if_statement attribute identifier identifier block if_statement not_operator attribute identifier identifier block raise_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier else_clause block delete_statement subscript identifier attribute identifier identifier if_statement identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier
helper for apply_sql in DropX case
def export_modified_data(self): def export_modfield(value, is_modified_seq=True): try: return value.export_modified_data() except AttributeError: if is_modified_seq: return value if self.__modified_data__ is not None: return [export_modfield(value) for value in self.__modified_data__] return list(x for x in [export_modfield(value) for value in self.__original_data__] if x is not None)
module function_definition identifier parameters identifier block function_definition identifier parameters identifier default_parameter identifier true block try_statement block return_statement call attribute identifier identifier argument_list except_clause identifier block if_statement identifier block return_statement identifier if_statement comparison_operator attribute identifier identifier none block return_statement list_comprehension call identifier argument_list identifier for_in_clause identifier attribute identifier identifier return_statement call identifier generator_expression identifier for_in_clause identifier list_comprehension call identifier argument_list identifier for_in_clause identifier attribute identifier identifier if_clause comparison_operator identifier none
Retrieves the modified data in a jsoned form
def ToCategorizedPath(path_type, components): try: prefix = { PathInfo.PathType.OS: ("fs", "os"), PathInfo.PathType.TSK: ("fs", "tsk"), PathInfo.PathType.REGISTRY: ("registry",), PathInfo.PathType.TEMP: ("temp",), }[path_type] except KeyError: raise ValueError("Unknown path type: `%s`" % path_type) return "/".join(itertools.chain(prefix, components))
module function_definition identifier parameters identifier identifier block try_statement block expression_statement assignment identifier subscript dictionary pair attribute attribute identifier identifier identifier tuple string string_start string_content string_end string string_start string_content string_end pair attribute attribute identifier identifier identifier tuple string string_start string_content string_end string string_start string_content string_end pair attribute attribute identifier identifier identifier tuple string string_start string_content string_end pair attribute attribute identifier identifier identifier tuple string string_start string_content string_end identifier except_clause identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier return_statement call attribute string string_start string_content string_end identifier argument_list call attribute identifier identifier argument_list identifier identifier
Translates a path type and a list of components to a categorized path.
def merge(cls, trees): first = trees[0] for tree in trees: first.update(tree) return first
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript identifier integer for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Merge a collection of AttrTree objects.
def _is_valid_cardinal(self, inpt, metadata): if not isinstance(inpt, int): return False if metadata.get_minimum_cardinal() and inpt < metadata.get_maximum_cardinal(): return False if metadata.get_maximum_cardinal() and inpt > metadata.get_minimum_cardinal(): return False if metadata.get_cardinal_set() and inpt not in metadata.get_cardinal_set(): return False else: return True
module function_definition identifier parameters identifier identifier identifier block if_statement not_operator call identifier argument_list identifier identifier block return_statement false if_statement boolean_operator call attribute identifier identifier argument_list comparison_operator identifier call attribute identifier identifier argument_list block return_statement false if_statement boolean_operator call attribute identifier identifier argument_list comparison_operator identifier call attribute identifier identifier argument_list block return_statement false if_statement boolean_operator call attribute identifier identifier argument_list comparison_operator identifier call attribute identifier identifier argument_list block return_statement false else_clause block return_statement true
Checks if input is a valid cardinal value
def _get_func_nodes(): return [definition for definition in project_definitions.values() if isinstance(definition.node, ast.FunctionDef)]
module function_definition identifier parameters block return_statement list_comprehension identifier for_in_clause identifier call attribute identifier identifier argument_list if_clause call identifier argument_list attribute identifier identifier attribute identifier identifier
Get all function nodes.
def process_fasta(fasta, **kwargs): logging.info("Nanoget: Starting to collect statistics from a fasta file.") inputfasta = handle_compressed_input(fasta, file_type="fasta") return ut.reduce_memory_usage(pd.DataFrame( data=[len(rec) for rec in SeqIO.parse(inputfasta, "fasta")], columns=["lengths"] ).dropna())
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier string string_start string_content string_end return_statement call attribute identifier identifier argument_list call attribute call attribute identifier identifier argument_list keyword_argument identifier list_comprehension call identifier argument_list identifier for_in_clause identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end keyword_argument identifier list string string_start string_content string_end identifier argument_list
Combine metrics extracted from a fasta file.
def _front_delta(self): if self.flags & self.NO_MOVE: return Separator(0, 0) if self.clicked and self.hovered: delta = 2 elif self.hovered and not self.flags & self.NO_HOVER: delta = 0 else: delta = 0 return Separator(delta, delta)
module function_definition identifier parameters identifier block if_statement binary_operator attribute identifier identifier attribute identifier identifier block return_statement call identifier argument_list integer integer if_statement boolean_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment identifier integer elif_clause boolean_operator attribute identifier identifier not_operator binary_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment identifier integer else_clause block expression_statement assignment identifier integer return_statement call identifier argument_list identifier identifier
Return the offset of the colored part.
def execute(self, proxy, method, args): try: result = getattr(proxy, method)(raw_xml=self.options.xml, *tuple(args)) except xmlrpc.ERRORS as exc: self.LOG.error("While calling %s(%s): %s" % (method, ", ".join(repr(i) for i in args), exc)) self.return_code = error.EX_NOINPUT if "not find" in getattr(exc, "faultString", "") else error.EX_DATAERR else: if not self.options.quiet: if self.options.repr: result = pformat(result) elif hasattr(result, "__iter__"): result = '\n'.join(i if isinstance(i, basestring) else pformat(i) for i in result) print(fmt.to_console(result))
module function_definition identifier parameters identifier identifier identifier identifier block try_statement block expression_statement assignment identifier call call identifier argument_list identifier identifier argument_list keyword_argument identifier attribute attribute identifier identifier identifier list_splat call identifier argument_list identifier except_clause as_pattern attribute identifier identifier as_pattern_target identifier block expression_statement call attribute attribute identifier identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier call attribute string string_start string_content string_end identifier generator_expression call identifier argument_list identifier for_in_clause identifier identifier identifier expression_statement assignment attribute identifier identifier conditional_expression attribute identifier identifier comparison_operator string string_start string_content string_end call identifier argument_list identifier string string_start string_content string_end string string_start string_end attribute identifier identifier else_clause block if_statement not_operator attribute attribute identifier identifier identifier block if_statement attribute attribute identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier elif_clause call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment identifier call attribute string string_start string_content escape_sequence string_end identifier generator_expression conditional_expression identifier call identifier argument_list identifier identifier call identifier argument_list identifier for_in_clause identifier identifier expression_statement call identifier argument_list call attribute identifier identifier argument_list identifier
Execute given XMLRPC call.
def export_public_key(user_id, env=None, sp=subprocess): args = gpg_command(['--export', user_id]) result = check_output(args=args, env=env, sp=sp) if not result: log.error('could not find public key %r in local GPG keyring', user_id) raise KeyError(user_id) return result
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier identifier block expression_statement assignment identifier call identifier argument_list list string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier if_statement not_operator identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier raise_statement call identifier argument_list identifier return_statement identifier
Export GPG public key for specified `user_id`.
def _convert_series(self, metric, ts): series = monitoring_v3.types.TimeSeries() series.metric.type = self.get_metric_type(metric.descriptor) for lk, lv in self.options.default_monitoring_labels.items(): series.metric.labels[lk.key] = lv.value for key, val in zip(metric.descriptor.label_keys, ts.label_values): if val.value is not None: safe_key = sanitize_label(key.key) series.metric.labels[safe_key] = val.value set_monitored_resource(series, self.options.resource) for point in ts.points: sd_point = series.points.add() self._convert_point(metric, ts, point, sd_point) return series
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute attribute identifier identifier identifier call attribute identifier identifier argument_list attribute identifier identifier for_statement pattern_list identifier identifier call attribute attribute attribute identifier identifier identifier identifier argument_list block expression_statement assignment subscript attribute attribute identifier identifier identifier attribute identifier identifier attribute identifier identifier for_statement pattern_list identifier identifier call identifier argument_list attribute attribute identifier identifier identifier attribute identifier identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment subscript attribute attribute identifier identifier identifier identifier attribute identifier identifier expression_statement call identifier argument_list identifier attribute attribute identifier identifier identifier for_statement identifier attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier identifier identifier identifier return_statement identifier
Convert an OC timeseries to a SD series.
def draw(self): from onshapepy import Part CAD = Part( 'https://cad.onshape.com/documents/b4cfd328713460beeb3125ac/w/3928b5c91bb0a0be7858d99e/e/6f2eeada21e494cebb49515f' ) CAD.params = { 'channel_L': self.channel_L, 'channel_W': self.channel_W, 'channel_H': self.downstream_H, 'channel_pairs': self.channel_n/2, 'baffle_S': self.baffle_S, }
module function_definition identifier parameters identifier block import_from_statement dotted_name identifier dotted_name identifier expression_statement assignment identifier call identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end binary_operator attribute identifier identifier integer pair string string_start string_content string_end attribute identifier identifier
Draw the Onshape flocculator model based off of this object.
def pytorch_id(node): return node.scopeName() + "/outputs/" + "/".join([o.uniqueName() for o in node.outputs()])
module function_definition identifier parameters identifier block return_statement binary_operator binary_operator call attribute identifier identifier argument_list string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list list_comprehension call attribute identifier identifier argument_list for_in_clause identifier call attribute identifier identifier argument_list
Returns a unique ID for a node.
def _addconfig(config, *paths): for path in paths: if path is not None and exists(path): config.append(path)
module function_definition identifier parameters identifier list_splat_pattern identifier block for_statement identifier identifier block if_statement boolean_operator comparison_operator identifier none call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier
Add path to CONF_DIRS if exists.
def init(self): self._context_notify_cb = pa_context_notify_cb_t( self.context_notify_cb) self._sink_info_cb = pa_sink_info_cb_t(self.sink_info_cb) self._update_cb = pa_context_subscribe_cb_t(self.update_cb) self._success_cb = pa_context_success_cb_t(self.success_cb) self._server_info_cb = pa_server_info_cb_t(self.server_info_cb) _mainloop = pa_threaded_mainloop_new() _mainloop_api = pa_threaded_mainloop_get_api(_mainloop) context = pa_context_new(_mainloop_api, "i3pystatus_pulseaudio".encode("ascii")) pa_context_set_state_callback(context, self._context_notify_cb, None) pa_context_connect(context, None, 0, None) pa_threaded_mainloop_start(_mainloop) self.colors = self.get_hex_color_range(self.color_muted, self.color_unmuted, 100) self.sinks = []
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier expression_statement assignment attribute identifier identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier call identifier argument_list expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier call attribute string string_start string_content string_end identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list identifier attribute identifier identifier none expression_statement call identifier argument_list identifier none integer none expression_statement call identifier argument_list identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier integer expression_statement assignment attribute identifier identifier list
Creates context, when context is ready context_notify_cb is called
def diagonalSize(self): szs = [a.diagonalSize() for a in self.actors] return np.max(szs)
module function_definition identifier parameters identifier block expression_statement assignment identifier list_comprehension call attribute identifier identifier argument_list for_in_clause identifier attribute identifier identifier return_statement call attribute identifier identifier argument_list identifier
Return the maximum diagonal size of the ``Actors`` of the ``Assembly``.
def _tscube_app(self, xmlfile): xmlfile = self.get_model_path(xmlfile) outfile = os.path.join(self.config['fileio']['workdir'], 'tscube%s.fits' % (self.config['file_suffix'])) kw = dict(cmap=self.files['ccube'], expcube=self.files['ltcube'], bexpmap=self.files['bexpmap'], irfs=self.config['gtlike']['irfs'], evtype=self.config['selection']['evtype'], srcmdl=xmlfile, nxpix=self.npix, nypix=self.npix, binsz=self.config['binning']['binsz'], xref=float(self.roi.skydir.ra.deg), yref=float(self.roi.skydir.dec.deg), proj=self.config['binning']['proj'], stlevel=0, coordsys=self.config['binning']['coordsys'], outfile=outfile) run_gtapp('gttscube', self.logger, kw)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end binary_operator string string_start string_content string_end parenthesized_expression subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list 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 subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end keyword_argument identifier subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end keyword_argument identifier call identifier argument_list attribute attribute attribute attribute identifier identifier identifier identifier identifier keyword_argument identifier call identifier argument_list attribute attribute attribute attribute identifier identifier identifier identifier identifier keyword_argument identifier subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end keyword_argument identifier integer keyword_argument identifier subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end keyword_argument identifier identifier expression_statement call identifier argument_list string string_start string_content string_end attribute identifier identifier identifier
Run gttscube as an application.
def main(): parser = argparse.ArgumentParser( description='Relocate a virtual environment.' ) parser.add_argument( '--source', help='The existing virtual environment.', required=True, ) parser.add_argument( '--destination', help='The location for which to configure the virtual environment.', required=True, ) parser.add_argument( '--move', help='Move the virtual environment to the destination.', default=False, action='store_true', ) args = parser.parse_args() relocate(args.source, args.destination, args.move)
module function_definition identifier parameters block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end keyword_argument 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 keyword_argument 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 keyword_argument identifier string string_start string_content string_end keyword_argument identifier false keyword_argument identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier
Relocate a virtual environment.
def _variable_type_to_read_fn(vartype, records): fn_map = {"String": "read_string", "Array[String]": "read_lines", "Array[Array[String]]": "read_tsv", "Object": "read_object", "Array[Object]": "read_objects", "Array[Array[Object]]": "read_objects", "Int": "read_int", "Float": "read_float"} for rec_name in records.keys(): fn_map["%s" % rec_name] = "read_struct" fn_map["Array[%s]" % rec_name] = "read_struct" fn_map["Array[Array[%s]]" % rec_name] = "read_struct" vartype = vartype.replace("File", "String") vartype = vartype.replace("Array[Int]", "Array[String]") vartype = vartype.replace("Array[Float]", "Array[String]") return fn_map[vartype]
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 pair string string_start string_content string_end string string_start string_content string_end for_statement identifier call attribute identifier identifier argument_list block expression_statement assignment subscript identifier binary_operator string string_start string_content string_end identifier string string_start string_content string_end expression_statement assignment subscript identifier binary_operator string string_start string_content string_end identifier string string_start string_content string_end expression_statement assignment subscript identifier binary_operator string string_start string_content string_end identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end return_statement subscript identifier identifier
Convert variant types into corresponding WDL standard library functions.
def reload_list(self): self.leetcode.load() if self.leetcode.quizzes and len(self.leetcode.quizzes) > 0: self.home_view = self.make_listview(self.leetcode.quizzes) self.view_stack = [] self.goto_view(self.home_view)
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list if_statement boolean_operator attribute attribute identifier identifier identifier comparison_operator call identifier argument_list attribute attribute identifier identifier identifier integer block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list attribute attribute identifier identifier identifier expression_statement assignment attribute identifier identifier list expression_statement call attribute identifier identifier argument_list attribute identifier identifier
Press R in home view to retrieve quiz list
def getParameterByName(self, name): result = None for parameter in self.getParameters(): nameParam = parameter.getName() if nameParam == name: result = parameter break return result
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier none for_statement identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier identifier block expression_statement assignment identifier identifier break_statement return_statement identifier
Searchs a parameter by name and returns it.
def afni_copy(filename): if nl.pkg_available('afni',True): afni_filename = "%s+orig" % nl.prefix(filename) if not os.path.exists(afni_filename + ".HEAD"): nl.calc(filename,'a',prefix=nl.prefix(filename)) return afni_filename
module function_definition identifier parameters identifier block if_statement call attribute identifier identifier argument_list string string_start string_content string_end true block expression_statement assignment identifier binary_operator string string_start string_content string_end call attribute identifier identifier argument_list identifier if_statement not_operator call attribute attribute identifier identifier identifier argument_list binary_operator identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list identifier string string_start string_content string_end keyword_argument identifier call attribute identifier identifier argument_list identifier return_statement identifier
creates a ``+orig`` copy of the given dataset and returns the filename as a string
def build(self, words): words = [self._normalize(tokens) for tokens in words] self._dawg = dawg.CompletionDAWG(words) self._loaded_model = True
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list_comprehension call attribute identifier identifier argument_list identifier for_in_clause identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier true
Construct dictionary DAWG from tokenized words.
def addSubparser(subparsers, subcommand, description): parser = subparsers.add_parser( subcommand, description=description, help=description) return parser
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier return_statement identifier
Add a subparser with subcommand to the subparsers object
def getApplicationsErrorNameFromEnum(self, error): fn = self.function_table.getApplicationsErrorNameFromEnum result = fn(error) return result
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list identifier return_statement identifier
Returns a string for an applications error
def _handle_continuations(self, response, cache_key): rcontinue = response.get('continue') listen = ['blcontinue', 'cmcontinue', 'plcontinue'] cparams = {} if rcontinue: for flag in listen: if rcontinue.get(flag): cparams[flag] = rcontinue.get(flag) if cparams: self.data['continue'] = cparams del self.cache[cache_key] else: if 'continue' in self.data: del self.data['continue']
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier dictionary if_statement identifier block for_statement identifier identifier block if_statement call attribute identifier identifier argument_list identifier block expression_statement assignment subscript identifier identifier call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end identifier delete_statement subscript attribute identifier identifier identifier else_clause block if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block delete_statement subscript attribute identifier identifier string string_start string_content string_end
Select continue params and clear cache or last continue params
def alignment(self): if self._arch is None: return NotImplemented return self.size // self._arch.byte_width
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block return_statement identifier return_statement binary_operator attribute identifier identifier attribute attribute identifier identifier identifier
The alignment of the type in bytes.
def sections_count(self): if not self._ptr: raise BfdException("BFD not initialized") return _bfd.get_bfd_attribute(self._ptr, BfdAttributes.COUNT_SECTIONS)
module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end return_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier
Return the sections_count attribute of the BFD file being processed.
def vector_str(p, decimal_places=2, print_zero=True): style = '{0:.' + str(decimal_places) + 'f}' return '[{0}]'.format(", ".join([' ' if not print_zero and a == 0 else style.format(a) for a in p]))
module function_definition identifier parameters identifier default_parameter identifier integer default_parameter identifier true block expression_statement assignment identifier binary_operator binary_operator string string_start string_content string_end call identifier argument_list identifier string string_start string_content string_end return_statement call attribute string string_start string_content string_end identifier argument_list call attribute string string_start string_content string_end identifier argument_list list_comprehension conditional_expression string string_start string_content string_end boolean_operator not_operator identifier comparison_operator identifier integer call attribute identifier identifier argument_list identifier for_in_clause identifier identifier
Pretty-print the vector values.
def _merge_report(self, target, new): time = None if 'ts' in new['parsed']: time = new['parsed']['ts'] if (target.get('lastSeenDate', None) and time and target['lastSeenDate'] < time): target['lastSeenDate'] = time query_millis = int(new['parsed']['stats']['millis']) target['stats']['totalTimeMillis'] += query_millis target['stats']['count'] += 1 target['stats']['avgTimeMillis'] = target['stats']['totalTimeMillis'] / target['stats']['count']
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier none if_statement comparison_operator string string_start string_content string_end subscript identifier string string_start string_content string_end block expression_statement assignment identifier subscript subscript identifier string string_start string_content string_end string string_start string_content string_end if_statement parenthesized_expression boolean_operator boolean_operator call attribute identifier identifier argument_list string string_start string_content string_end none identifier comparison_operator subscript identifier string string_start string_content string_end identifier block expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list subscript subscript subscript identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement augmented_assignment subscript subscript identifier string string_start string_content string_end string string_start string_content string_end identifier expression_statement augmented_assignment subscript subscript identifier string string_start string_content string_end string string_start string_content string_end integer expression_statement assignment subscript subscript identifier string string_start string_content string_end string string_start string_content string_end binary_operator subscript subscript identifier string string_start string_content string_end string string_start string_content string_end subscript subscript identifier string string_start string_content string_end string string_start string_content string_end
Merges a new report into the target report
def expect(func, args, times=7, sleep_t=0.5): while times > 0: try: return func(*args) except Exception as e: times -= 1 logger.debug("expect failed - attempts left: %d" % times) time.sleep(sleep_t) if times == 0: raise exceptions.BaseExc(e)
module function_definition identifier parameters identifier identifier default_parameter identifier integer default_parameter identifier float block while_statement comparison_operator identifier integer block try_statement block return_statement call identifier argument_list list_splat identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement augmented_assignment identifier integer expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier integer block raise_statement call attribute identifier identifier argument_list identifier
try many times as in times with sleep time
def _create_alignment_button(self): iconnames = ["AlignTop", "AlignCenter", "AlignBottom"] bmplist = [icons[iconname] for iconname in iconnames] self.alignment_tb = _widgets.BitmapToggleButton(self, bmplist) self.alignment_tb.SetToolTipString(_(u"Alignment")) self.Bind(wx.EVT_BUTTON, self.OnAlignment, self.alignment_tb) self.AddControl(self.alignment_tb)
module function_definition identifier parameters identifier block expression_statement assignment identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier list_comprehension subscript identifier identifier for_in_clause identifier identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list call identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier
Creates vertical alignment button
def query(self, query, variables=None, timeout=None, metadata=None, credentials=None): new_metadata = self._dg.add_login_metadata(metadata) req = self._common_query(query, variables=variables) try: res = self._dc.query(req, timeout=timeout, metadata=new_metadata, credentials=credentials) except Exception as error: if util.is_jwt_expired(error): self._dg.retry_login() new_metadata = self._dg.add_login_metadata(metadata) res = self._dc.query(req, timeout=timeout, metadata=new_metadata, credentials=credentials) else: raise error self.merge_context(res.txn) return res
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier try_statement block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier except_clause as_pattern identifier as_pattern_target identifier block if_statement call attribute identifier identifier argument_list identifier block expression_statement call attribute attribute identifier identifier identifier argument_list 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 identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier else_clause block raise_statement identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier return_statement identifier
Adds a query operation to the transaction.
def read_line(self, fid): lin = ' while lin[0] == ' lin = fid.readline().strip() if lin == '': return lin return lin
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call attribute call attribute identifier identifier argument_list identifier argument_list if_statement comparison_operator identifier string string_start string_end block return_statement identifier return_statement identifier
Read a line from a file string and check it isn't either empty or commented before returning.
def _convert_clause(self, clause): clause = wrap(clause) if clause == None: return None elif is_data(clause): return set_default({"value": self.convert(clause.value)}, clause) else: return [set_default({"value": self.convert(c.value)}, c) for c in clause]
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier none block return_statement none elif_clause call identifier argument_list identifier block return_statement call identifier argument_list dictionary pair string string_start string_content string_end call attribute identifier identifier argument_list attribute identifier identifier identifier else_clause block return_statement list_comprehension call identifier argument_list dictionary pair string string_start string_content string_end call attribute identifier identifier argument_list attribute identifier identifier identifier for_in_clause identifier identifier
JSON QUERY EXPRESSIONS HAVE MANY CLAUSES WITH SIMILAR COLUMN DELCARATIONS
def top(self): if self.vMerge is None or self.vMerge == ST_Merge.RESTART: return self._tr_idx return self._tc_above.top
module function_definition identifier parameters identifier block if_statement boolean_operator comparison_operator attribute identifier identifier none comparison_operator attribute identifier identifier attribute identifier identifier block return_statement attribute identifier identifier return_statement attribute attribute identifier identifier identifier
The top-most row index in the vertical span of this cell.
def _get_serv(ret=None): _options = _get_options(ret) host = _options.get('host') port = _options.get('port') database = _options.get('db') user = _options.get('user') password = _options.get('password') version = _get_version(host, port, user, password) if version and "v0.8" in version: return influxdb.influxdb08.InfluxDBClient(host=host, port=port, username=user, password=password, database=database ) else: return influxdb.InfluxDBClient(host=host, port=port, username=user, password=password, database=database )
module function_definition identifier parameters default_parameter identifier none block expression_statement assignment identifier call identifier argument_list identifier 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 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 expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier identifier identifier identifier if_statement boolean_operator identifier comparison_operator string string_start string_content string_end identifier block return_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier else_clause block 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
Return an influxdb client object
def to_latex(self): if self.low == self.high: if self.low * 10 % 10 == 0: return "{0:d}".format(int(self.low)) else: return "{0:0.2f}".format(self.low) else: t = "" if self.low == -np.inf: t += r"(-\infty, " elif self.low * 10 % 10 == 0: t += r"[{0:d}, ".format(int(self.low)) else: t += r"[{0:0.2f}, ".format(self.low) if self.high == np.inf: t += r"\infty)" elif self.high * 10 % 10 == 0: t += r"{0:d}]".format(int(self.high)) else: t += r"{0:0.2f}]".format(self.high) return t
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block if_statement comparison_operator binary_operator binary_operator attribute identifier identifier integer integer integer block return_statement call attribute string string_start string_content string_end identifier argument_list call identifier argument_list attribute identifier identifier else_clause block return_statement call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier else_clause block expression_statement assignment identifier string string_start string_end if_statement comparison_operator attribute identifier identifier unary_operator attribute identifier identifier block expression_statement augmented_assignment identifier string string_start string_content string_end elif_clause comparison_operator binary_operator binary_operator attribute identifier identifier integer integer integer block expression_statement augmented_assignment identifier call attribute string string_start string_content string_end identifier argument_list call identifier argument_list attribute identifier identifier else_clause block expression_statement augmented_assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement augmented_assignment identifier string string_start string_content string_end elif_clause comparison_operator binary_operator binary_operator attribute identifier identifier integer integer integer block expression_statement augmented_assignment identifier call attribute string string_start string_content string_end identifier argument_list call identifier argument_list attribute identifier identifier else_clause block expression_statement augmented_assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier return_statement identifier
Returns an interval representation
def fromJD(jd, utcoffset): if not isinstance(utcoffset, Time): utcoffset = Time(utcoffset) localJD = jd + utcoffset.value / 24.0 date = Date(round(localJD)) time = Time((localJD + 0.5 - date.jdn) * 24) return Datetime(date, time, utcoffset)
module function_definition identifier parameters identifier identifier block if_statement not_operator call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier binary_operator identifier binary_operator attribute identifier identifier float expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list binary_operator parenthesized_expression binary_operator binary_operator identifier float attribute identifier identifier integer return_statement call identifier argument_list identifier identifier identifier
Builds a Datetime object given a jd and utc offset.
def cli(env, identifier, ack): manager = AccountManager(env.client) event = manager.get_event(identifier) if ack: manager.ack_event(identifier) env.fout(basic_event_table(event)) env.fout(impacted_table(event)) env.fout(update_table(event))
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier
Details of a specific event, and ability to acknowledge event.
def build_package(path, requires, virtualenv=None, ignore=None, extra_files=None, zipfile_name=ZIPFILE_NAME, pyexec=None): pkg = Package(path, zipfile_name, pyexec) if extra_files: for fil in extra_files: pkg.extra_file(fil) if virtualenv is not None: pkg.virtualenv(virtualenv) pkg.requirements(requires) pkg.build(ignore) return pkg
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier identifier default_parameter identifier none block expression_statement assignment identifier call identifier argument_list identifier identifier identifier if_statement identifier block for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Builds the zip file and creates the package with it
def train(self, data, **kwargs): self.data = data for i in xrange(0,data.shape[1]): column_mean = np.mean(data.icol(i)) column_stdev = np.std(data.icol(i)) self.column_means += [column_mean] self.column_stdevs += [column_stdev] self.data = self.predict(data)
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block expression_statement assignment attribute identifier identifier identifier for_statement identifier call identifier argument_list integer subscript attribute identifier identifier integer block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier expression_statement augmented_assignment attribute identifier identifier list identifier expression_statement augmented_assignment attribute identifier identifier list identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier
Calculate the standard deviations and means in the training data
def _die(self, msg, lnum): raise Exception("**FATAL {FILE}({LNUM}): {MSG}\n".format( FILE=self.obo_file, LNUM=lnum, MSG=msg))
module function_definition identifier parameters identifier identifier identifier block raise_statement call identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
Raise an Exception if file read is unexpected.
def multipleOrderComparison(cls, orders): comparers = [ (o.keyfn, 1 if o.isAscending() else -1) for o in orders] def cmpfn(a, b): for keyfn, ascOrDesc in comparers: comparison = cmp(keyfn(a), keyfn(b)) * ascOrDesc if comparison is not 0: return comparison return 0 return cmpfn
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list_comprehension tuple attribute identifier identifier conditional_expression integer call attribute identifier identifier argument_list unary_operator integer for_in_clause identifier identifier function_definition identifier parameters identifier identifier block for_statement pattern_list identifier identifier identifier block expression_statement assignment identifier binary_operator call identifier argument_list call identifier argument_list identifier call identifier argument_list identifier identifier if_statement comparison_operator identifier integer block return_statement identifier return_statement integer return_statement identifier
Returns a function that will compare two items according to `orders`
def quick_search(self, terms): assert type(terms) is str p = [{'quicksearch': terms}] return self.search_bugs(p)
module function_definition identifier parameters identifier identifier block assert_statement comparison_operator call identifier argument_list identifier identifier expression_statement assignment identifier list dictionary pair string string_start string_content string_end identifier return_statement call attribute identifier identifier argument_list identifier
Wrapper for search_bugs, for simple string searches
def comparable(self): document_dict = self.compare_safe(self._document) self._remove_keys(document_dict, self._uncompared_fields) clean_document_dict = {} for k, v in document_dict.items(): if not v and not isinstance(v, (int, float)): continue clean_document_dict[k] = v for ref_field, ref_cls in self._compared_refs.items(): ref = getattr(self, ref_field) if not ref: continue if isinstance(ref, list): if isinstance(ref[0], Frame): continue setattr( clean_document_dict, ref_field, ref_cls.many(In(Q._id, ref)) ) else: if isinstance(ref, Frame): continue setattr( clean_document_dict, ref_field, ref_cls.byId(ref) ) return clean_document_dict
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier expression_statement assignment identifier dictionary for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement boolean_operator not_operator identifier not_operator call identifier argument_list identifier tuple identifier identifier block continue_statement expression_statement assignment subscript identifier identifier identifier for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block expression_statement assignment identifier call identifier argument_list identifier identifier if_statement not_operator identifier block continue_statement if_statement call identifier argument_list identifier identifier block if_statement call identifier argument_list subscript identifier integer identifier block continue_statement expression_statement call identifier argument_list identifier identifier call attribute identifier identifier argument_list call identifier argument_list attribute identifier identifier identifier else_clause block if_statement call identifier argument_list identifier identifier block continue_statement expression_statement call identifier argument_list identifier identifier call attribute identifier identifier argument_list identifier return_statement identifier
Return a dictionary that can be compared
def status_code(self): try: return self._status_code except AttributeError: self._status_code = self._response.getcode() return self._status_code
module function_definition identifier parameters identifier block try_statement block return_statement attribute identifier identifier except_clause identifier block expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list return_statement attribute identifier identifier
Get the http status code for the response
def update_from_sam(self, sam, sam_reader): if sam.is_unmapped \ or sam.mate_is_unmapped \ or (sam.reference_id == sam.next_reference_id): return new_link = link.Link(sam, sam_reader, self.ref_lengths) read_name = sam.query_name if read_name in self.partial_links: new_link.merge(self.partial_links[read_name]) del self.partial_links[read_name] key = tuple(sorted((new_link.refnames[0], new_link.refnames[1]))) if key not in self.links: self.links[key] = [] new_link.sort() self.links[key].append(new_link) else: self.partial_links[read_name] = new_link
module function_definition identifier parameters identifier identifier identifier block if_statement boolean_operator boolean_operator attribute identifier identifier line_continuation attribute identifier identifier line_continuation parenthesized_expression comparison_operator attribute identifier identifier attribute identifier identifier block return_statement expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier if_statement comparison_operator identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list subscript attribute identifier identifier identifier delete_statement subscript attribute identifier identifier identifier expression_statement assignment identifier call identifier argument_list call identifier argument_list tuple subscript attribute identifier identifier integer subscript attribute identifier identifier integer if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier list expression_statement call attribute identifier identifier argument_list expression_statement call attribute subscript attribute identifier identifier identifier identifier argument_list identifier else_clause block expression_statement assignment subscript attribute identifier identifier identifier identifier
Updates graph info from a pysam.AlignedSegment object
def hex2termhex(hexval: str, allow_short: bool = False) -> str: return rgb2termhex(*hex2rgb(hexval, allow_short=allow_short))
module function_definition identifier parameters typed_parameter identifier type identifier typed_default_parameter identifier type identifier false type identifier block return_statement call identifier argument_list list_splat call identifier argument_list identifier keyword_argument identifier identifier
Convert a hex value into the nearest terminal color matched hex.
def hash_user_id(self, user_id: str) -> str: h = sha256() h.update(user_id.encode()) return h.hexdigest()
module function_definition identifier parameters identifier typed_parameter identifier type identifier type identifier block expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list return_statement call attribute identifier identifier argument_list
As per the law, anonymize user identifier before sending it.
def _entity_list_as_bel(entities: Iterable[BaseEntity]) -> str: return ', '.join( e.as_bel() for e in entities )
module function_definition identifier parameters typed_parameter identifier type generic_type identifier type_parameter type identifier type identifier block return_statement call attribute string string_start string_content string_end identifier generator_expression call attribute identifier identifier argument_list for_in_clause identifier identifier
Stringify a list of BEL entities.
def _two_byte_cmd(self, cmd): if cmd == SB: self.telnet_got_sb = True self.telnet_sb_buffer = '' elif cmd == SE: self.telnet_got_sb = False self._sb_decoder() elif cmd == NOP: pass elif cmd == DATMK: pass elif cmd == IP: pass elif cmd == AO: pass elif cmd == AYT: pass elif cmd == EC: pass elif cmd == EL: pass elif cmd == GA: pass else: print "2BC: Should not be here." self.telnet_got_iac = False self.telnet_got_cmd = None
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier identifier block expression_statement assignment attribute identifier identifier true expression_statement assignment attribute identifier identifier string string_start string_end elif_clause comparison_operator identifier identifier block expression_statement assignment attribute identifier identifier false expression_statement call attribute identifier identifier argument_list elif_clause comparison_operator identifier identifier block pass_statement elif_clause comparison_operator identifier identifier block pass_statement elif_clause comparison_operator identifier identifier block pass_statement elif_clause comparison_operator identifier identifier block pass_statement elif_clause comparison_operator identifier identifier block pass_statement elif_clause comparison_operator identifier identifier block pass_statement elif_clause comparison_operator identifier identifier block pass_statement elif_clause comparison_operator identifier identifier block pass_statement else_clause block print_statement string string_start string_content string_end expression_statement assignment attribute identifier identifier false expression_statement assignment attribute identifier identifier none
Handle incoming Telnet commands that are two bytes long.
def append_default_stylesheets(self): for style in utils.get_stylesheet_list(self.settings): self.css(style)
module function_definition identifier parameters identifier block for_statement identifier call attribute identifier identifier argument_list attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier
Appends the default styles defined on the translator settings.